From 1b7cf8ca8bbcad1be9ad4767f9a344272f2acce9 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Fri, 13 Feb 2009 09:27:55 +0100
Subject: [PATCH] Some more utility functions

---
 src/Utils.hs | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/Utils.hs b/src/Utils.hs
index d54bdde0a..d771a0b63 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 ","
-- 
GitLab