[Haskell-cafe] Decimal type-level arithmetic.

2011-05-31 Thread Serguey Zefirov
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.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Decimal type-level arithmetic.

2011-05-31 Thread Henning Thielemann


On Wed, 1 Jun 2011, Serguey Zefirov wrote:


I would like to present my version of type arithmetic with decimal
encoding: http://thesz.mskhug.ru/svn/hhdl/TyleA.hs


How does it compare to
  http://hackage.haskell.org/package/type-level
?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Decimal type-level arithmetic.

2011-05-31 Thread Serguey Zefirov
2011/6/1 Henning Thielemann lemm...@henning-thielemann.de:

 On Wed, 1 Jun 2011, Serguey Zefirov wrote:
 I would like to present my version of type arithmetic with decimal
 encoding: http://thesz.mskhug.ru/svn/hhdl/TyleA.hs
 How does it compare to
  http://hackage.haskell.org/package/type-level
 ?

My version is slightly simpler to use, I think, because type-level
uses functional dependencies: Type-level functions are implemented
using functional dependencies of multi parameter type classes.

I use type families.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe