
7 Aug
2013
7 Aug
'13
12:06 a.m.
Christopher Done wrote:
How about popping these in Data.Either?
-- | Maybe get the left side of an Either. leftToMaybe :: Either a b -> Maybe a leftToMaybe = either Just (const Nothing)
-- | Maybe get the right side of an Either. rightToMaybe :: Either a b -> Maybe b rightToMaybe = either (const Nothing) Just
+1 And while we're at it: isLeft :: Either a b -> Bool isLeft (Left _) = True isLeft (Right _) = False isRight :: Either a b -> Bool isRight (Left _) = False isRight (Right _) = True Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/