Added a useful transformEither function to Utils

This commit is contained in:
Neil Brown 2007-08-18 15:37:29 +00:00
parent 68a3b3f4bc
commit f700392676

View File

@ -34,3 +34,8 @@ doMaybe :: Monad m => Maybe (m ()) -> m ()
doMaybe (Just a) = a
doMaybe Nothing = return ()
-- | Transforms between two Either types using the appropriate convert function:
transformEither :: (a -> c) -> (b -> d) -> Either a b -> Either c d
transformEither funcLeft funcRight x = case x of
Left l -> Left (funcLeft l)
Right r -> Right (funcRight r)