Re: [Haskell-cafe] Re: Maybe to Either -- is there a better way?

2010-08-03 Thread Tom Davies
On 03/08/2010, at 10:09 PM, Ertugrul Soeylemez wrote: > Tom Davies wrote: > >> I find it convenient sometimes to convert a Maybe value to an Either >> thus (excuse the syntax, it's CAL, not Haskell): >> >> maybeToEither :: a -> Maybe b -> Either a b; >> maybeToEither errorValue = maybe (Left e

[Haskell-cafe] Re: Maybe to Either -- is there a better way?

2010-08-03 Thread Ertugrul Soeylemez
Tom Davies wrote: > I find it convenient sometimes to convert a Maybe value to an Either > thus (excuse the syntax, it's CAL, not Haskell): > > maybeToEither :: a -> Maybe b -> Either a b; > maybeToEither errorValue = maybe (Left errorValue) (\x -> Right x); As a side note, this is perfectly val