[Haskell-cafe] Strange subtract operator behavior - and lazy naturals

Stuart Cook scook0 at gmail.com
Wed Oct 17 06:51:14 EDT 2007


On 10/17/07, John Meacham <john at repetae.net> wrote:
> if anyone is interested, Although I bet this has been implemented a
> hundred times over, I have attached my lazy naturals module below just
> for larks. It is quite efficient as such things go and very lazy. for
> instance (genericLength xs > 5) will only evaluate up to the 5th element
> of the list before returning a result. and ((1 `div` 0) > 17) is true,
> not bottom.

> If anyone wants me to clean this up and package it as a real module, I
> would be happy to do so.

It looks like there's already a lazy-natural type in the "numbers"
package on Hackage, but not having used it I have no idea what it's
like.

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/numbers-2007.9.25
http://tinyurl.com/2pmthz


Stuart


More information about the Haskell-Cafe mailing list