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

David Virebayre dav.vire+haskell at gmail.com
Thu May 6 04:05:05 EDT 2010


On Thu, May 6, 2010 at 9:56 AM, Eugene Dzhurinsky <bofh at redwerk.com> wrote:
> On Wed, May 05, 2010 at 02:54:27PM -0700, Ryan Ingram wrote:
>> ErrorT is just a newtype wrapper, changing the order/application of
>> the type variables.
>>
>> newtype ErrorT e m a = ErrorT (m (Either e a))
>> runErrorT (ErrorT action) = action
>>
>> This gives the bijection:
>>
>> ErrorT :: m (Either e a) -> ErrorT e m a
>> runErrorT :: ErrorT e m a -> m (Either e a)
>
> That syntax is not clear for me - so ErrorT is some sort of function
> (calculation), which takes a monad with type (Either e a) and produces type
> ErrorT e m a ? Basically, i don't understand what does "ErrorT ::" means - it
> should name the function - but it starts with capital letter?

A constructor can be seen as a function that takes some parameters and
produces a value

for example with the type Maybe a, which has 2 constructors ; Just and Nothing :

Prelude> :t Just
Just :: a -> Maybe a

the constructor Just is a function that takes a value of type a and
makes a value of type Maybe a.

Prelude> :t Just
Just :: a -> Maybe a

David.


More information about the Haskell-Cafe mailing list