Re: [Haskell-cafe] ErrorT vs Either

2011-05-17 Thread Daniel Fischer
On Tuesday 17 May 2011 01:40:41, Gracjan Polak wrote: > Daniel Fischer googlemail.com> writes: > > On Monday 16 May 2011 23:41:44, Gracjan Polak wrote: > > > Thanks Daniel, Yves and Edward for explanation. Two things come to > > > my mind now. > > > > > > 1. It should be unified. > > > > The (Ei

Re: [Haskell-cafe] ErrorT vs Either

2011-05-16 Thread Felipe Almeida Lessa
On Mon, May 16, 2011 at 8:40 PM, Gracjan Polak wrote: >  result <- runErrorT $ do >     lift $ print "was here" >     fail "msg" > >  (result = Left "msg") > > after a while the print statement may be removed: > >  result <- runErrorT $ do >     fail "msg" > >  (result = Left "msg") That seems pr

Re: [Haskell-cafe] ErrorT vs Either

2011-05-16 Thread Gracjan Polak
Daniel Fischer googlemail.com> writes: > > On Monday 16 May 2011 23:41:44, Gracjan Polak wrote: > > Thanks Daniel, Yves and Edward for explanation. Two things come to my > > mind now. > > > > 1. It should be unified. > > The (Either e) Monad instance was recently changed after people have long

Re: [Haskell-cafe] ErrorT vs Either

2011-05-16 Thread Daniel Fischer
On Monday 16 May 2011 23:41:44, Gracjan Polak wrote: > Thanks Daniel, Yves and Edward for explanation. Two things come to my > mind now. > > 1. It should be unified. The (Either e) Monad instance was recently changed after people have long complained that there shouldn't be an (Error e) constrai

Re: [Haskell-cafe] ErrorT vs Either

2011-05-16 Thread Antoine Latter
On Mon, May 16, 2011 at 4:41 PM, Gracjan Polak wrote: > > 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" ::

Re: [Haskell-cafe] ErrorT vs Either

2011-05-16 Thread Gracjan Polak
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

Re: [Haskell-cafe] ErrorT vs Either

2011-05-16 Thread Daniel Fischer
On Monday 16 May 2011 23:05:22, Yves Parès wrote: > Probably because in the instance of Monad Either, fail has not been > overloaded, and still has its default implementation: > fail = error Right. It used to be different in mtl-1.*, when there was an instance Error e => Monad (Either e) where

Re: [Haskell-cafe] ErrorT vs Either

2011-05-16 Thread Edward Amsden
I suspect it is because the "fail" method for the 'Either' monad instance makes use of Haskell's error function, since the instance is defined generally and there is no way to override it for (Either String a). On May 16, 2011, Gracjan Polak wrote: > Control.Monad.Error Prelude> runErrorT (fail

Re: [Haskell-cafe] ErrorT vs Either

2011-05-16 Thread Yves Parès
Probably because in the instance of Monad Either, fail has not been overloaded, and still has its default implementation: fail = error Whereas runErrorT explicitely catches the exception. 2011/5/16 Gracjan Polak > > Hi all, > > A why question: Why: > > Control.Monad.Error Prelude> runErrorT (fa

[Haskell-cafe] ErrorT vs Either

2011-05-16 Thread Gracjan Polak
Hi all, A why question: Why: Control.Monad.Error Prelude> runErrorT (fail "msg") :: IO (Either String Int) Left "msg" but Control.Monad.Error Prelude> (fail "msg") :: (Either String Int) *** Exception: msg ? -- Gracjan ___ Haskell-Cafe mailing