on master help sign in
Applicative instance for (Either e)
commit04642a85bfa263f1378942cd8f9c0534a2909b04 authorstartling <tdixon51793@gmail.com> dateThu 15 Nov 2012, 13:38 (14 years ago) parent894a847
1 file changed+6
lib/Prelude.idr+6
lib/Prelude.idr+6
@@ -121,6 +121,12 @@ instance Applicative Maybe where
121121 (Just f) <$> (Just a) = Just (f a)
122122 _ <$> _ = Nothing
123123
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
124130
125131---- some mathematical operations
126132