on master help sign in
Applicative instance for (Either e)
04642a8startling
lib/Prelude.idr+6
@@ -121,6 +121,12 @@ instance Applicative Maybe where
121 (Just f) <$> (Just a) = Just (f a)
121 (Just f) <$> (Just a) = Just (f a)
122 _ <$> _ = Nothing
122 _ <$> _ = Nothing
123
123
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
124
130
125---- some mathematical operations
131---- some mathematical operations
126
132