[Haskell-cafe] Recursion problem in infinite list model

Luke Palmer lrpalmer at gmail.com
Thu Mar 27 12:51:17 EDT 2008


A few comments:

On Thu, Mar 27, 2008 at 2:55 PM, Hans Aberg <haberg at math.su.se> wrote:
>  The reason I used a "data" construct was that I include the size of
>  the list, excluded in order to keep the example as simple as possible:
>    data List a = List(Ordinal -> a, Ordinal)

This could still be a newtype, because of the tuple you used here.  A
more standard
way to do this would be:

    data List a = List (Ordinal -> a) Ordinal

Or a record so you could name them.

By your naming, am I correct in assuming that you're implementing
transfinite lists?
If so, cool!

>  In addition, there seems to be no way to choose default value for a
>  given (non-empty) type in Haskell, so I wrote it
>    data List a = Empty | List(Ordinal -> a, Ordinal)
>  Here, if a type T has a default element t, I can represent the empty
>  list by
>    List(\_ -> t, 0)
>  making the constructor "Empty" redundant.

You could use 'undefined', which has value _|_  (if you're sure that
it will never
be used).

  List (const undefined) 0

Or even:

  List undefined 0

Which are almost, but not quite, identical.  (Many argue they should be)

Luke


More information about the Haskell-Cafe mailing list