[Haskell-cafe] Unique Ordered Types
will.yager at gmail.com
Thu Aug 13 00:58:31 UTC 2015
What kind of units are these? dimensional normalizes units by representing them like Foo Int Int Int. (Those are type-level "ints".)
So if length is Foo 1 0 0 and time is Foo 0 1 0, then length* time = Foo 1 1 0 = time* length.
Does this work for your application?
> On Aug 12, 2015, at 14:20, Silvio Frischknecht <silvio.frischi at gmail.com> wrote:
> Hi I'm experimenting with a unit system in haskell where users can add
> "base units". I want to reduce units after multiplication and bring it
> into a canonical form. The problem is what kind of types can the units have.
> data UnitA
> data UnitB
> Problem: They can't be ordered so UnitA * UnitB can be compared to UnitB
> * UnitA, but I can't make a canonical form, which would make type
> inference a lot better.
> type UnitA = Zero
> type UnitB = Suc Zero
> Problem: Now they can be ordered. But users can create conflicting
> "basic units"
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe