[Haskell-cafe] IO (Either a Error) question

David Virebayre dav.vire+haskell at gmail.com
Thu May 6 07:52:13 EDT 2010


By the way, I didn't exactly reply your question :

> [...] Basically, i don't understand what does "ErrorT ::" means - it
> should name the function - but it starts with capital letter?

It's a type signature, it describes the type of ErrorT:

Prelude> import Control.Monad.Error
Prelude Control.Monad.Error> :t ErrorT
ErrorT :: m (Either e a) -> ErrorT e m a

So that says, ErrorT is a value constructor that takes a value of type
m (Either e a) and makes a value of type ErrorT e m a.

Notice that the type constructor and the value constructor have both
the same name ErrorT, I used to get confused by this when I began
learning.

If you type under ghci

Prelude Control.Monad.Error> :k ErrorT
ErrorT :: * -> (* -> *) -> * -> *

That tells you that ErrorT is a type constructor that takes a type, a
unary type constructor, and a type; and with all this defines a new
type (ErrorT e m a).

David.


More information about the Haskell-Cafe mailing list