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

2007-10-17 Thread Henning Thielemann
On Tue, 16 Oct 2007, Peter Verswyvelen wrote: Concurrent Clean uses the ~ symbol for unary negation. That's also a way of fixing it. Personally I could also live with allowing no space between the minus sign and the number... If you leave a space, - becomes the subtract operator. Me

Re: [Haskell-cafe] Strange subtract operator behavior

2007-10-17 Thread Peter Verswyvelen
Duh, you're right... silly me. I always put spaces between the operator, but many people of course don't. Isaac Dupree wrote: Peter Verswyvelen wrote: Personally I could also live with allowing no space between the minus sign and the number... If you leave a space, - becomes the subtract

Re: [Haskell-cafe] Strange subtract operator behavior

2007-10-17 Thread Peter Verswyvelen
Yes, I guessed it would. Actually logging all those discussions is a good idea: I will make a wiki page containing all the discussions I have with my wife, and then - at the start of a new discussion - I can redirect her to the wiki page. Problem solved, no energy wasted ;-) Okay,

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

2007-10-16 Thread Neil Mitchell
Hi (/ 10) means the function that divides its argument by 10 (- 10) however is just the number -10, even if I put a space between the - and 10. How can I create a function that subtracts 10 from its argument in a clean way then? subtract is the way to go. (`subtract` 10) I think you

Re: [Haskell-cafe] Strange subtract operator behavior

2007-10-16 Thread Derek Elkins
On Tue, 2007-10-16 at 17:02 +0100, Neil Mitchell wrote: Hi (/ 10) means the function that divides its argument by 10 (- 10) however is just the number -10, even if I put a space between the - and 10. How can I create a function that subtracts 10 from its argument in a clean way

Re: [Haskell-cafe] Strange subtract operator behavior

2007-10-16 Thread Neil Mitchell
Hi I think you should have to write negative numbers using the syntax 0-10, since currently having one single unary operator is ugly. I think writing 0-10 is ugly. Ugly - yes. But very clear as to its meaning. How often do people actually write negative numeric literals? My guess is that

Re: [Haskell-cafe] Strange subtract operator behavior

2007-10-16 Thread Michael Campbell
On 10/16/07, Neil Mitchell [EMAIL PROTECTED] wrote: Ugly - yes. But very clear as to its meaning. How often do people actually write negative numeric literals? Any time I need one. And I can guarantee I don't make the compiler perform an arithmetic computation to get one, either. -- Wise

Re: [Haskell-cafe] Strange subtract operator behavior

2007-10-16 Thread David Christensen
I think you should have to write negative numbers using the syntax 0-10, since currently having one single unary operator is ugly. I think writing 0-10 is ugly. Ugly - yes. But very clear as to its meaning. How often do people actually write negative numeric literals? My guess is that -1 is

Re: [Haskell-cafe] Strange subtract operator behavior

2007-10-16 Thread Peter Verswyvelen
Concurrent Clean uses the ~ symbol for unary negation. That's also a way of fixing it. Personally I could also live with allowing no space between the minus sign and the number... If you leave a space, - becomes the subtract operator. Coming from C++ I always make the mistake to forget

Re: [Haskell-cafe] Strange subtract operator behavior

2007-10-16 Thread Isaac Dupree
Peter Verswyvelen wrote: Personally I could also live with allowing no space between the minus sign and the number... If you leave a space, - becomes the subtract operator. I once thought that... there was the opposition that (x-1) subtraction of a constant appears too often. And I found

Re: [Haskell-cafe] Strange subtract operator behavior

2007-10-16 Thread John Meacham
On Tue, Oct 16, 2007 at 06:27:19PM -0300, Isaac Dupree wrote: Peter Verswyvelen wrote: Personally I could also live with allowing no space between the minus sign and the number... If you leave a space, - becomes the subtract operator. I once thought that... there was the opposition that

Re: [Haskell-cafe] Strange subtract operator behavior

2007-10-16 Thread Lennart Augustsson
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. :) ) -- Lennart On 10/17/07, John Meacham [EMAIL PROTECTED] wrote: On Tue, Oct 16, 2007 at 06:27:19PM -0300, Isaac

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