[Haskell-cafe] ANNOUNCE: numtype 1.0 -- Type-level (low cardinality) integers

Bjorn Buckwalter bjorn.buckwalter at gmail.com
Sat Jun 6 17:51:10 EDT 2009

Dear all,

Since its inception my dimensional library has been built around a
unary type-level representation of integers (NumTypes) defined in the
Numeric.NumType module. This module has proven itself useful outside
the context of dimensional and after dragging my feet for a long time
I've finally gotten around packaging it up in its own library:

The Numeric.NumType module is completely self-contained (only imports
Prelude) and is heavily commented in a narrative manner inspired by
Oleg Kiselyov's expositions. I believe it provides a good case study
for type-level programming with multi-parameter type classes and
functional dependencies.

Addition, subtraction, division, and multiplication of NumTypes is
supported. NumTypes have no value-level representation but can be
converted to any Num instance with the 'toNum' function.

The numtype library has two significant short-comings:

* Minimal haddocks -- as with my dimensional library the literate
  Haskell source code is the documentation. The flip-side is that
  the code is very well-commented.

* Due to the unary implementation the practical size of the
  NumTypes is severely limited, making them unsuitable for
  large-cardinality applications. If you will be working with
  integers beyond (-20, 20) this package probably isn't for you.

(If the second bullet is a show-stopper Edward Kmett's type-int[2]
library may be a better choice. Peter Gavin's tfp[3] library also
provides type-level integers but uses type families instead of MPTCs
and fundeps. I cannot vouch for either of these libraries as I haven't
used them.)

Numtype version 1.0 can be downloaded from Hackage or the dimensional
project page[4]. I've also updated dimensional to version 0.8 with the
Numeric.NumType module removed and Julian 'year' and 'century' units
added. Enjoy!

Bjorn Buckwalter

[1]:  http://code.google.com/p/dimensional/wiki/numtype
[2]:  http://hackage.haskell.org/cgi-bin/hackage-scripts/package/type-int
[3]:  http://hackage.haskell.org/cgi-bin/hackage-scripts/package/tfp
[4]:  http://dimensional.googlecode.com

More information about the Haskell-Cafe mailing list