@@ -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
@@ -100,6 +106,10 @@ instance Functor Maybe where
100106 fmap f (Just x) = Just (f x)
101107 fmap f Nothing = Nothing
102108
109+instance Functor (Either e) where
110+ fmap f (Left l) = Left l
111+ fmap f (Right r) = Right (f r)
112+
103113instance Functor List where
104114 fmap = map
105115
@@ -111,6 +121,17 @@ instance Applicative Maybe where
111121 (Just f) <$> (Just a) = Just (f a)
112122 _ <$> _ = Nothing
113123
124+instance Applicative (Either e) where
125+ pure = Right
126+
127+ (Left a) <$> _ = Left a
128+ (Right f) <$> (Right r) = Right (f r)
129+ (Right _) <$> (Left l) = Left l
130+
131+instance Applicative List where
132+ pure x = [x]
133+
134+ fs <$> vs = concatMap (\f => map f vs) fs
114135
115136---- some mathematical operations
116137