From c4702a7f6ef03a852afec98167edc8996e08c5a3 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Fri, 30 May 2008 17:14:28 +0000 Subject: [PATCH] Added a new helper function, eitherToMaybe in Utils --- common/Utils.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/Utils.hs b/common/Utils.hs index 2d93709..8046a35 100644 --- a/common/Utils.hs +++ b/common/Utils.hs @@ -312,5 +312,9 @@ mapMapWithKeyM f m = liftM Map.fromAscList $ mapM f' $ Map.toAscList m f' (x,y) = do y' <- f 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