diff --git a/src/Utils.hs b/src/Utils.hs index d54bdde0a7b53947824e6704fe15964bf8601420..d771a0b63c40bbaba4dd8188167910f6a6f78dbc 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -3,6 +3,7 @@ module Utils where import Data.List +import Data.Either import Debug.Trace @@ -10,6 +11,19 @@ import Debug.Trace debug :: Show a => a -> a debug x = trace (show x) x +-- | Check if the given argument is Left something +isLeft :: Either a b -> Bool +isLeft val = + case val of + Left _ -> True + _ -> False + +fromLeft :: Either a b -> a +fromLeft = either (\x -> x) (\_ -> undefined) + +fromRight :: Either a b -> b +fromRight = either (\_ -> undefined) id + -- | Comma-join a string list. commaJoin :: [String] -> String commaJoin = intercalate ","