[Haskell-cafe] Lazy Lists and IO
Andrew Coppin
andrewcoppin at btinternet.com
Thu Jul 12 14:03:48 EDT 2007
Jonathan Cast wrote:
> On Wednesday 11 July 2007, Chaddaï Fouché wrote:
>
>> Is there something I misunderstood in the exchange ?
>>
>
> Yeah. The reference to the "lazy natural type", which is:
>
> data Nat
> = Zero
> | Succ Nat
> deriving (Eq, Ord, Read, Show)
>
> instance Num Nat where
> fromInteger 0 = Zero
> fromInteger (n + 1) = Succ (fromInteger n)
> etc.
>
> then genericLength xn > n does exactly what Andrew wants, when n :: Nat.
>
Wow.
Show me a simple problem, and some Haskeller somewhere will find a
completely unexpected way to solve it... LOL!
OTOH, doesn't that just mean that Nat is itself a degenerate list, and
genericList is just converting one list to another, and the Ord instance
for Nat is doing the short-cut stuff?
More information about the Haskell-Cafe
mailing list