on master help sign in
Monad instance for (Either e)
commit4043a0cd5074fa69d55de95570cc3db93b4eee2f authorstartling <tdixon51793@gmail.com> dateThu 15 Nov 2012, 13:33 (14 years ago) parenteea2d4a
1 file changed+6
lib/Prelude.idr+6
lib/Prelude.idr+6
@@ -86,6 +86,12 @@ instance MonadPlus Maybe where
8686 mplus Nothing (Just y) = Just y
8787 mplus Nothing Nothing = Nothing
8888
89+instance Monad (Either e) where
90+ return = Right
91+
92+ (Left n) >>= _ = Left n
93+ (Right r) >>= f = f r
94+
8995instance Monad List where
9096 return x = [x]
9197 m >>= f = concatMap f m