broken Monad Either instance?
Edward Kmett
ekmett at gmail.com
Sat Dec 3 10:22:12 CET 2011
This would be wonderful, but as you noted, the obvious choice conflicts with the unfortunately named Error class used for ErrorT's argument. I usually use err, Err and runErr in my own code for what you describe.
Sent from my iPad
On Dec 2, 2011, at 11:13 AM, Twan van Laarhoven <twanvl at gmail.com> wrote:
> On 30/11/11 13:55, Christian Maeder wrote:
>> Yes, thanks, this works and is worth knowing.
>> It looks a bit ugly but is shorter than making a new monad.
>>
>> Prelude Control.Monad.Identity Control.Monad.Error>
>> runIdentity . runErrorT $ fail "bla" :: Either String ()
>> Left "bla"
>
> We should also add a type synonym for Error, like there is for Reader, State and RWS:
>
> type Error e a = ErrorT e a
> error :: Either e a -> Error e a
> error = ErrorT . Indentity
> runError :: Error e a -> Either e a
> runError = runIdentity . runErrorT
> mapError :: Error e a -> Error f a
> mapError f = mapErrorT (Identity . f . runIdentity)
>
> The only problem is that the name 'Error' is taken by a typeclass, and 'error' by everyone's least favorite prelude function.
>
>
> Twan
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
More information about the Libraries
mailing list