Tom Davies <tgdav...@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);
As a side note, this is perfectly valid Haskell code, even though it's quite verbose. The equivalent: maybeToEither :: a -> Maybe b -> Either a b maybeToEither leftValue = maybe (Left leftValue) Right Honestly I find this better than the completely points-free variants posted in the other subthread. They demonstrate overusing points-free style. Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://ertes.de/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe