[Haskell-cafe] ErrorT vs Either

Gracjan Polak gracjanpolak at gmail.com
Mon May 16 23:41:44 CEST 2011


Thanks Daniel, Yves and Edward for explanation. Two things come to my mind now.

1. It should be unified. Why? Because conceptually:

runIdentity (runErrorT (fail "msg")) :: Either String Int
Left "msg"

and 

fail "msg" :: Either String Int
*** Exception: msg

Should be the same as Identity monad should not add structure.

2. I need a Failure monad that works well with pattern match failures (that call
fail). I'd like to use it like this:

    runErrorT $ do
         Active <- getStatus                -- ensure proper status
         Just elm <- lookup stuff there     -- lookup element
         when (condition) $ fail "wrong!"   -- check condition
         return 1234                        -- return useful value

sort of... Any ideas what could be used in place of Either monad? Basically I
need working pattern match failures (I guess that means I need working fail
method that is not equal to error).

-- 
Gracjan





More information about the Haskell-Cafe mailing list