[Haskell-cafe] Decimal type-level arithmetic.
Serguey Zefirov
sergueyz at gmail.com
Tue May 31 22:46:51 CEST 2011
I would like to present my version of type arithmetic with decimal
encoding: http://thesz.mskhug.ru/svn/hhdl/TyleA.hs
It is not worth Cabal package in its current state, but I hope it
would be useful for someone.
It is easy to use, just say Plus (D1 :. D2 :. D0) D8 to get a type of
128. Or you can say $(tySize 128) if you're not afraid to use
Template Haskell.
I tested it on my current project, it works quite well with numbers
around 128..512, about 10-20 times faster than Peano numbers.
As operations over this representation are not lazy (Peano numbers
oeprations are lazy for one argument of Plus and for part of one
argument of Max), it is not well suited for big number of operations
done at once.
I encountered it when I autogenerated a big arithmetic expression for
big polymorphic data type. I think it is quite rare situation.
More information about the Haskell-Cafe
mailing list