on master help sign in
Remove "return" from Monad
d0460a3David Christiansen
lib/Control/IOExcept.idr−1
@@ -16,7 +16,6 @@ instance Applicative (IOExcept e) where
16 return (f' <$> a'))
16 return (f' <$> a'))
17
17
18instance Monad (IOExcept e) where
18instance Monad (IOExcept e) where
19− return = pure
20 (ioM x) >>= k = ioM (do x' <- x;
19 (ioM x) >>= k = ioM (do x' <- x;
21 case x' of
20 case x' of
22 Right a => let (ioM ka) = k a in
21 Right a => let (ioM ka) = k a in
lib/Control/Monad/Identity.idr−1
@@ -16,5 +16,4 @@ instance Applicative Identity where
16 (Id f) <$> (Id g) = Id (f g)
16 (Id f) <$> (Id g) = Id (f g)
17
17
18instance Monad Identity where
18instance Monad Identity where
19− return x = Id x
20 (Id x) >>= k = k x
19 (Id x) >>= k = k x
lib/Control/Monad/State.idr−2
@@ -27,8 +27,6 @@ instance Monad f => Applicative (StateT s f) where
27 return (g b, t))
27 return (g b, t))
28
28
29instance Monad m => Monad (StateT s m) where
29instance Monad m => Monad (StateT s m) where
30− return x = ST (\st => return (x, st))
31−
32 (ST f) >>= k = ST (\st => do (v, st') <- f st
30 (ST f) >>= k = ST (\st => do (v, st') <- f st
33 let ST kv = k v
31 let ST kv = k v
34 kv st')
32 kv st')
lib/Data/Morphisms.idr−1
@@ -30,7 +30,6 @@ instance Applicative (Morphism r) where
30 (Mor f) <$> (Mor a) = Mor $ \r => f r $ a r
30 (Mor f) <$> (Mor a) = Mor $ \r => f r $ a r
31
31
32instance Monad (Morphism r) where
32instance Monad (Morphism r) where
33− return a = Mor $ const a
34 (Mor h) >>= f = Mor $ \r => applyMor (f $ h r) r
33 (Mor h) >>= f = Mor $ \r => applyMor (f $ h r) r
35
34
36instance Semigroup (Endomorphism a) where
35instance Semigroup (Endomorphism a) where
lib/Network/Cgi.idr−2
@@ -41,8 +41,6 @@ instance Applicative CGI where
41instance Monad CGI where {
41instance Monad CGI where {
42 (>>=) (MkCGI f) k = MkCGI (\s => do v <- f s
42 (>>=) (MkCGI f) k = MkCGI (\s => do v <- f s
43 getAction (k (fst v)) (snd v))
43 getAction (k (fst v)) (snd v))
44−
45− return v = MkCGI (\s => return (v, s))
46}
44}
47
45
48setInfo : CGIInfo -> CGI ()
46setInfo : CGIInfo -> CGI ()
lib/Prelude.idr−6
@@ -124,23 +124,17 @@ instance Alternative List where
124---- Monad instances
124---- Monad instances
125
125
126instance Monad IO where
126instance Monad IO where
127− return t = io_return t
128 b >>= k = io_bind b k
127 b >>= k = io_bind b k
129
128
130instance Monad Maybe where
129instance Monad Maybe where
131− return t = Just t
132−
133 Nothing >>= k = Nothing
130 Nothing >>= k = Nothing
134 (Just x) >>= k = k x
131 (Just x) >>= k = k x
135
132
136instance Monad (Either e) where
133instance Monad (Either e) where
137− return = Right
138−
139 (Left n) >>= _ = Left n
134 (Left n) >>= _ = Left n
140 (Right r) >>= f = f r
135 (Right r) >>= f = f r
141
136
142instance Monad List where
137instance Monad List where
143− return x = [x]
144 m >>= f = concatMap f m
138 m >>= f = concatMap f m
145
139
146---- some mathematical operations
140---- some mathematical operations
lib/Prelude/Monad.idr+3−1
@@ -11,8 +11,10 @@ import Prelude.Applicative
11infixl 5 >>=
11infixl 5 >>=
12
12
13class Applicative m => Monad (m : Type -> Type) where
13class Applicative m => Monad (m : Type -> Type) where
14− return : a -> m a
15 (>>=) : m a -> (a -> m b) -> m b
14 (>>=) : m a -> (a -> m b) -> m b
16
15
17flatten : Monad m => m (m a) -> m a
16flatten : Monad m => m (m a) -> m a
18flatten a = a >>= id
17flatten a = a >>= id
18+
19+return : Monad m => a -> m a
20+return = pure
lib/System/Concurrency/Process.idr−1
@@ -23,7 +23,6 @@ instance Applicative (Process msg) where
23 (lift f) <$> (lift a) = lift (f <$> a)
23 (lift f) <$> (lift a) = lift (f <$> a)
24
24
25instance Monad (Process msg) where
25instance Monad (Process msg) where
26− return = lift . return
27 (lift io) >>= k = lift (do x <- io
26 (lift io) >>= k = lift (do x <- io
28 case k x of
27 case k x of
29 lift v => v)
28 lift v => v)