@@ -109,6 +109,19 @@ instance Applicative List where
110 fs <$> vs = concatMap (\f => map f vs) fs
110 fs <$> vs = concatMap (\f => map f vs) fs
112+---- Alternative instances
114+instance Alternative Maybe where
117+ (Just x) <|> _ = Just x
120+instance Alternative List where
112---- Monad instances
125---- Monad instances
114instance Monad IO where
127instance Monad IO where
@@ -121,13 +134,6 @@ instance Monad Maybe where
121 Nothing >>= k = Nothing
134 Nothing >>= k = Nothing
122 (Just x) >>= k = k x
135 (Just x) >>= k = k x
124−instance MonadPlus Maybe where
127− mplus (Just x) _ = Just x
128− mplus Nothing (Just y) = Just y
129− mplus Nothing Nothing = Nothing
131instance Monad (Either e) where
137instance Monad (Either e) where
132 return = Right
138 return = Right
@@ -138,10 +144,6 @@ instance Monad List where
138 return x = [x]
144 return x = [x]
139 m >>= f = concatMap f m
145 m >>= f = concatMap f m
141−instance MonadPlus List where
145---- some mathematical operations
147---- some mathematical operations
147%include "math.h"
149%include "math.h"