Re: [Haskell-cafe] Natural Numbers: Best implementation?

2009-03-16 Thread Wolfgang Jeltsch
Am Samstag, 14. März 2009 23:33 schrieben Sie: On Fri, 13 Mar 2009, Wolfgang Jeltsch wrote: Class instances should satisfy certain laws. (Although these laws are often not stated explicitely, they are assumed to hold by users of the class and they should hold to make the instance sensible.)

Re: [Haskell-cafe] Natural Numbers: Best implementation?

2009-03-14 Thread Henning Thielemann
On Fri, 13 Mar 2009, Mark Spezzano wrote: 1.  Don’t bother. Just use Integer. 2.  Use the type data Natural = Zero | Succ !Natural 3.  Use the following definition taken from the Gentle Introduction to Haskell 98 newtype Natural = MakeNatural Integer This option looks like non-negative

Re: [Haskell-cafe] Natural Numbers: Best implementation?

2009-03-14 Thread Henning Thielemann
On Fri, 13 Mar 2009, Wolfgang Jeltsch wrote: Am Freitag, 13. März 2009 09:21 schrieb Roman Cheplyaka: * Alexander Dunlap alexander.dun...@gmail.com [2009-03-12 20:01:57-0700] Also, a lot of functions just take Integers so it would be more of a pain to use. AFAIK there are very few

Re: [Haskell-cafe] Natural Numbers: Best implementation?

2009-03-13 Thread Sebastian Fischer
Hi Mark, On Mar 13, 2009, at 3:54 AM, Mark Spezzano wrote: I was wondering what the best way to implement Natural number would be. Is there a package which already does this? there are two packages on Hackage that implement natural numbers using algebraic datatypes: 'numbers' has a module

Re: [Haskell-cafe] Natural Numbers: Best implementation?

2009-03-13 Thread Roman Cheplyaka
* Alexander Dunlap alexander.dun...@gmail.com [2009-03-12 20:01:57-0700] Also, a lot of functions just take Integers so it would be more of a pain to use. AFAIK there are very few fuctions that take Integers. Many functions take instances of Integral, but it's not a problem to make your own

Re: [Haskell-cafe] Natural Numbers: Best implementation?

2009-03-13 Thread Wolfgang Jeltsch
Am Freitag, 13. März 2009 04:01 schrieb Alexander Dunlap: 2.  Use the type data Natural = Zero | Succ !Natural […] In terms of speed, I think that [3] would be reasonably fast (unless you do a ton of subtraction with bounds-checking) and [2] would probably be quite slow, because you

Re: [Haskell-cafe] Natural Numbers: Best implementation?

2009-03-13 Thread Wolfgang Jeltsch
Am Freitag, 13. März 2009 04:53 schrieb Brandon S. Allbery KF8NH: On 2009 Mar 12, at 22:54, Mark Spezzano wrote: I was wondering what the best way to implement Natural number would be. Is there a package which already does this? type-level on Hackage. I think, the original poster wanted

Re: [Haskell-cafe] Natural Numbers: Best implementation?

2009-03-13 Thread Wolfgang Jeltsch
Am Freitag, 13. März 2009 09:21 schrieb Roman Cheplyaka: * Alexander Dunlap alexander.dun...@gmail.com [2009-03-12 20:01:57-0700] Also, a lot of functions just take Integers so it would be more of a pain to use. AFAIK there are very few fuctions that take Integers. Many functions take

Re: [Haskell-cafe] Natural Numbers: Best implementation?

2009-03-13 Thread Brandon S. Allbery KF8NH
On 2009 Mar 13, at 4:25, Wolfgang Jeltsch wrote: Am Freitag, 13. März 2009 04:53 schrieb Brandon S. Allbery KF8NH: On 2009 Mar 12, at 22:54, Mark Spezzano wrote: I was wondering what the best way to implement Natural number would be. Is there a package which already does this? type-level on

[Haskell-cafe] Natural Numbers: Best implementation?

2009-03-12 Thread Mark Spezzano
Hi, I was wondering what the best way to implement Natural number would be. Is there a package which already does this? Here are some options: 1. Don’t bother. Just use Integer. 2. Use the type data Natural = Zero | Succ !Natural 3. Use the following definition taken from the

Re: [Haskell-cafe] Natural Numbers: Best implementation?

2009-03-12 Thread Alexander Dunlap
2009/3/12 Mark Spezzano mark.spezz...@chariot.net.au: Hi, I was wondering what the best way to implement Natural number would be. Is there a package which already does this? Here are some options: 1.  Don’t bother. Just use Integer. 2.  Use the type data Natural = Zero | Succ

Re: [Haskell-cafe] Natural Numbers: Best implementation?

2009-03-12 Thread Brandon S. Allbery KF8NH
On 2009 Mar 12, at 22:54, Mark Spezzano wrote: I was wondering what the best way to implement Natural number would be. Is there a package which already does this? type-level on Hackage. 2. Use the type data Natural = Zero | Succ !Natural One of the reasons people use type-level naturals