From f700392676c2d80db2c15a44d292dd1fa502a7bf Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Sat, 18 Aug 2007 15:37:29 +0000 Subject: [PATCH] Added a useful transformEither function to Utils --- Utils.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Utils.hs b/Utils.hs index 2bb3ee0..74fe67c 100644 --- a/Utils.hs +++ b/Utils.hs @@ -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)