[Haskell-cafe] mutually recursive types

Tillmann Rendel rendel at rbg.informatik.tu-darmstadt.de
Wed Aug 8 11:17:31 EDT 2007

Rodrigo wrote:
> type Scenario = (String, String, [Step])
> type Step = (String, Scenario, String, String, String)

Recursive types are not supported by type-declarations. use data 
declarations instead:

   data Scenario = Scenario String String [Step]
   data Step = Step String Scenario String String String

As a general rule, data declaration are more approbiate then type 
declarations with a tuple on the right-hand-side. a type declarations 
introduces a type synonym, that is, a new name for an existing type. 
Data declarations introduce a new type. most of the time, you want new 
types, not more names for the same types. different names for the same 
thing lead to confusion, but different things for different usages lead 
to static type safety.

(But this is only a general rule, and sometimes you want exactly the 
behaviour of type synonyms, of course)


More information about the Haskell-Cafe mailing list