Another way to defer the evaluation of the second argument of (-+) is like this:

(-+) :: a -> List a -> List a
x -+ y = List(f) where
  f 0 = x
  f k = case y of List g -> g (k-1)

This is exactly what the lazy pattern will do at compile-time.  Does
this give you a better understanding of how lazy patterns work and why
they fix the problem?

  -- ryan

On 3/27/08, Hans Aberg <[EMAIL PROTECTED]> wrote:
> On 27 Mar 2008, at 17:51, Luke Palmer wrote:
>
> > A more standard way to do this would be:
> >
> >     data List a = List (Ordinal -> a) Ordinal
>
> I used
>   data List a = Empty | (Ordinal->a) :+ Ordinal
> which might then be simplified by dropping "Empty".
>
>   Hans Aberg
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to