Added a new helper function, eitherToMaybe in Utils

This commit is contained in:
Neil Brown 2008-05-30 17:14:28 +00:00
parent 1a1e78a9c4
commit c4702a7f6e

View File

@ -312,5 +312,9 @@ mapMapWithKeyM f m = liftM Map.fromAscList $ mapM f' $ Map.toAscList m
f' (x,y) = do y' <- f x y f' (x,y) = do y' <- f x y
return (x, y') return (x, y')
-- | Transforms an Either into a Maybe. If it's a Left value, it is transformed
-- into Nothing. If it is a Right value, it is transformed into Just.
eitherToMaybe :: Either a b -> Maybe b
eitherToMaybe = either (const Nothing) Just