[Haskell-cafe] Unique Ordered Types

Christopher Allen cma at bitemyapp.com
Wed Aug 12 21:24:51 UTC 2015


http://hackage.haskell.org/package/units is a pretty deep example of how to
have type-safe units.

On Wed, Aug 12, 2015 at 4:20 PM, 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.
>
> 1)
>
> 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.
>
> 2)
>
> type UnitA = Zero
> type UnitB = Suc Zero
>
> Problem: Now they can be ordered. But users can create conflicting
> "basic units"
>
>
>
> Silvio
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>



-- 
Chris Allen
Currently working on http://haskellbook.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150812/14f46200/attachment.html>


More information about the Haskell-Cafe mailing list