Can someone give me some tips / advice on creating level integers in OCaml (3.12) that support addition and subtraction operations on them?
For example, if I have numbers represented as follows:
type zero
type 'a succ
type pos1 = zero succ
type pos2 = zero succ succ
...
I need a way to define a function for these types:
val add: pos2 -> pos1 -> pos3
Small background: I'm trying to transfer some haskell code for operations with physical dimensions, and I need the ability to define operations on dimension types (a record of 7 types of type level representing exponents of 7 basic SI units). I need to do this in such a way as to avoid dynamic binding (when using objects) and let the compiler evaluate and check all such expressions statically.
, GADT, , , .