<div dir="ltr"><a href="http://hackage.haskell.org/package/units">http://hackage.haskell.org/package/units</a> is a pretty deep example of how to have type-safe units.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 12, 2015 at 4:20 PM, Silvio Frischknecht <span dir="ltr"><<a href="mailto:silvio.frischi@gmail.com" target="_blank">silvio.frischi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi I'm experimenting with a unit system in haskell where users can add<br>
"base units". I want to reduce units after multiplication and bring it<br>
into a canonical form. The problem is what kind of types can the units have.<br>
<br>
1)<br>
<br>
data UnitA<br>
data UnitB<br>
<br>
Problem: They can't be ordered so UnitA * UnitB can be compared to UnitB<br>
* UnitA, but I can't make a canonical form, which would make type<br>
inference a lot better.<br>
<br>
2)<br>
<br>
type UnitA = Zero<br>
type UnitB = Suc Zero<br>
<br>
Problem: Now they can be ordered. But users can create conflicting<br>
"basic units"<br>
<br>
<br>
<br>
Silvio<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr">Chris Allen<br><div><span style="font-size:12.8000001907349px">Currently working onĀ </span><a href="http://haskellbook.com" target="_blank">http://haskellbook.com</a></div></div></div></div></div></div>
</div>