A type constructor is better called a "type descriptor"

Submitted by metaperl on Sat, 04/22/2006 - 9:07am.

A type "constructor" just describes what a data constructor builds. It doesn't construct anything and shouldn't be called a constructor.

Submitted by Derek Elkins on Sat, 04/22/2006 - 2:10pm.

It constructs a type, exactly like a data constructor constructs a piece of data.

Just 3 :: Maybe Int :: *
Just :: Int -> Maybe Int
Maybe :: * -> *
Submitted by lightstep on Sat, 04/22/2006 - 2:14pm.

A type constructor does create a new type: it's a function from the types to the types.

For example, the kind of Either is (* -> * -> *), where * is the kind of simple types. Wwhen applied to two type paramaters, as is Either String Char, you get a type (a thing with kind *).

Actually, the definition of types is very similar to the definition of functions and values in haskell, except you don't have pattern matching. This is due to not having an advanced kind system. Also, you need to add a constructor when using newtype. Here are some examples:

data Nil -- kind *
newtype Apply a b = Applied (a b) -- kind (* -> *) -> * -> *
newtype Y t = Y (t (Y t)) -- kind (* -> *) -> *

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.