[Haskell-beginners] a bunch o' questions

Ricardo Carnieri carnieri at gmail.com
Thu Jul 1 12:49:59 EDT 2010


> Leaf and Branch are type-constructors, and "Tree a" is a parametrized type.

I think this is wrong. Leaf and Branch are *data* constructors, and
Tree is, indeed, a type constructor.

>From http://www.haskell.org/all_about_monads/html/meet.html :
-------------------------------------------------------------------------------
Type constructors

To understand monads in Haskell, you need to be comfortable dealing
with type constructors. A type constructor is a parameterized type
definition used with polymorphic types. By supplying a type
constructor with one or more concrete types, you can construct a new
concrete type in Haskell. In the definition of Maybe:

  data Maybe a = Nothing | Just a

Maybe is a type constructor and Nothing and Just are data
constructors. You can construct a data value by applying the Just data
constructor to a value:

  country = Just "China"

In the same way, you can construct a type by applying the Maybe type
constructor to a type:

  lookupAge :: DB -> String -> Maybe Int


Best regards,
Ricardo Carnieri


More information about the Beginners mailing list