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

2007-10-22 Thread Aaron Denney
On 2007-10-21, Yitzchak Gale [EMAIL PROTECTED] wrote:
 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 = IntDiff Nat Nat
 The only value which would diverge when
 compared to a constant would be infinity - infinity.

 Hmm. But then you could have integers that are
 divergent and non-infinite. What do we gain by
 doing it this way?

IntDiff is essentially fail-lazily for (Infinity - Infinity), rather
than fail-quickly of the other two.  Sometimes fail-lazily is
appropriate, sometimes not.  I don't think it makes too much difference
here though.  My actual concern is about having to compute with IntDiff
(large) (large + x) many times instead of IntDiff 0 x.  I'd rather one
of the two above, though I think I'd prefer explicity PosInt and NegInt
branches over an inscrutable boolean flag.

-- 
Aaron Denney
--

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


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

2007-10-18 Thread Jon Fairbairn
David Benbennick [EMAIL PROTECTED] writes:

 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 call, interleaving
 the elements of the two arguments.

 Thanks.

 Have you thought at all about how to make maximally lazy Naturals?
 For example, a data type that can answer True to both

 genericLength (1:undefined) + genericLength (1:2:3:4:5:6:undefined)  (6 :: 
 Nat)

 genericLength (1:2:3:4:5:6:undefined) + genericLength (1:undefined)  (6 :: 
 Nat)

 Is that a desired feature?

It may be desirable, but it's not lambda definable, so you'd
have to use concurrency to acheive it.

-- 
Jón Fairbairn [EMAIL PROTECTED]


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