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

Christopher Done chrisdone at googlemail.com
Mon Aug 2 10:44:24 EDT 2010

It's available in MissingH:


You can find this using Hayoo, which indexes Hackage.

MissingH is pretty huge, though, just for one function. It's kind of
annoying. I'm using this function in my library and one other, in the
hopes I'll need more to make depending on MissingH worth it.

On 2 August 2010 16:14, Tom Davies <tgdavies at gmail.com> 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);
> but that seemingly obvious function isn't in Hoogle, AFAICT, so perhaps there's some other approach?
> Thanks,
>  Tom_______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list