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

2007-10-21 Thread Yitzchak Gale
I wrote: Yitzchak Gale wrote: So why not make the laziness available also for cases where 1 - 2 == 0 does _not_ do the right thing? data LazyInteger = IntZero | IntSum Bool Integer LazyInteger or data LazyInteger = LazyInteger Bool Nat or whatever. Luke Palmer wrote: data LazyInteger

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

2007-10-20 Thread Luke Palmer
On 10/19/07, Yitzchak Gale [EMAIL PROTECTED] wrote: So why not make the laziness available also for cases where 1 - 2 == 0 does _not_ do the right thing? data LazyInteger = IntZero | IntSum Bool Integer LazyInteger or data LazyInteger = LazyInteger Bool Nat I think data LazyInteger

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

2007-10-19 Thread Yitzchak Gale
Hi John, I wrote: - Zero really means 0, not 0 or negative You wrote: Actually, zero does mean zero. There is no such thing as negative numbers in the naturals so it doesn't make sense to say '0 or negative'. Well, then, 0 or error, or 0 or nothing. It clearly does not mean zero.

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

2007-10-18 Thread Yitzchak Gale
I wrote: Nice, lots of fun! Wouldn't it be more convenient to allow them to be signed? John Meacham wrote: Well, a couple reasons. One is that Natural numbers are a pretty useful type in and of themselves, often times when used with lazy evaluation. The other is that it is unclear what

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

2007-10-18 Thread John Meacham
On Thu, Oct 18, 2007 at 01:58:14PM +0200, Yitzchak Gale wrote: - Zero really means 0, not 0 or negative. Actually, zero does mean zero. There is no such thing as negative numbers in the naturals so it doesn't make sense to say '0 or negative'. Subtraction is necessarily defined differently of

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

2007-10-17 Thread Yitzchak Gale
John Meacham 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. Nice, lots of fun! Wouldn't it be more convenient to allow them to be signed? True, you can't have laziness in certain

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

2007-10-17 Thread Stuart Cook
On 10/17/07, John Meacham [EMAIL PROTECTED] 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)

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

2007-10-17 Thread Lennart Augustsson
The one in the numbers package is not quite as clever as John's; it's the naïve version of lazy naturals. On 10/17/07, Stuart Cook [EMAIL PROTECTED] wrote: On 10/17/07, John Meacham [EMAIL PROTECTED] wrote: if anyone is interested, Although I bet this has been implemented a hundred times

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

2007-10-17 Thread John Meacham
On Wed, Oct 17, 2007 at 12:41:54PM +0200, Yitzchak Gale wrote: John Meacham 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. Nice, lots of fun! Wouldn't it be more convenient to

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

2007-10-17 Thread John Meacham
On Wed, Oct 17, 2007 at 09:16:47PM +0100, Lennart Augustsson wrote: The one in the numbers package is not quite as clever as John's; it's the naïve version of lazy naturals. it appears to also be left biased in general, mine are symmetric and commutative whenever possible and things like its

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

2007-10-17 Thread David Benbennick
This module doesn't appear to be very lazy to me. For example, in ghci, *Util.LazyNum List genericLength (1:2:undefined) (1 :: Nat) *** Exception: Prelude.undefined How is this module intended to be used? ___ Haskell-Cafe mailing list

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

2007-10-17 Thread John Meacham
On Wed, Oct 17, 2007 at 05:43:08PM -0700, David Benbennick wrote: This module doesn't appear to be very lazy to me. For example, in ghci, *Util.LazyNum List genericLength (1:2:undefined) (1 :: Nat) *** Exception: Prelude.undefined How is this module intended to be used? Oops, sorry, the

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

2007-10-17 Thread David Benbennick
On 10/17/07, John Meacham [EMAIL PROTECTED] wrote: Oops, sorry, the version I posted was an intermediate one that had a different addition algorithm. here is a better one that fixes that issue: Zero + y = y Sum x n1 + y = Sum x (y + n1) note that it alternates the order in the recursive

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

2007-10-16 Thread John Meacham
On Wed, Oct 17, 2007 at 03:13:23AM +0100, Lennart Augustsson wrote: If naturals have a perfectly reasonable subtraction then they also have a perfectly reasonable negate; the default is 0-x. (Oh, subtraction wasn't THAT reasonable, you say. :) ) I suppose I was overextending the use of