[Haskell-beginners] data type design question

Jason Dusek jason.dusek at gmail.com
Wed Jul 30 15:28:36 EDT 2008

  A data declaration _defines_ type constructors. You describe
  what types those constructors can accept, so this:

    data T
      = TString String
      | TInt Integer
      | TList [T]
      | TDict [(TString, T)]

  actually doesn't make any sense -- the list holds what? Holds
  tuples of `TString` and `T`. What type is `TString` ? It's not
  a type, it's a constructor! So you need to make it a type.

  Also, it is not clear to me why the `TDict` can not just map
  `String`s to `T`s -- if you get a `TString` in the course of
  parsing, you can unwrap it.


More information about the Beginners mailing list