recursive type


recursive type

A data type which contains itself. The commonest example isthe list type, in Haskell:

data List a = Nil | Cons a (List a)

which says a list of a's is either an empty list or a cons cell containing an 'a' (the "head" of the list) and anotherlist (the "tail").

Recursion is not allowed in Miranda or Haskell synonym types, so the following Haskell types are illegal:

type Bad = (Int, Bad)type Evil = Bool -> Evil

whereas the seeminly equivalent algebraic data types areacceptable:

data Good = Pair Int Gooddata Fine = Fun (Bool->Fine)