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)