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

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Thu Oct 18 05:38:05 EDT 2007


"David Benbennick" <dbenbenn at gmail.com> writes:

> On 10/17/07, John Meacham <john at repetae.net> 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                                 Jon.Fairbairn at cl.cam.ac.uk




More information about the Haskell-Cafe mailing list