on master help sign in
Merge pull request #76 from hvr/pr/canonical-monad-instances

Canonicalise Monad instances

commit1cc39a865c6194e202d058bf84f6a97ebae1b5c9 authorMichael Snoyman <michael@snoyman.com> dateSun 29 Nov 2015, 15:34 (11 years ago) parent913919b2b64a68
2 files changed+4−4
Data/Yaml/Internal.hs+2−2 Data/Yaml/Parser.hs+2−2
Data/Yaml/Internal.hs+2−2
@@ -108,10 +108,10 @@ newtype PErrorT m a = PErrorT { runPErrorT :: m (Either ParseException a) }
108108instance Monad m => Functor (PErrorT m) where
109109 fmap = liftM
110110instance Monad m => Applicative (PErrorT m) where
111− pure = return
111+ pure = PErrorT . return . Right
112112 (<*>) = ap
113113instance Monad m => Monad (PErrorT m) where
114− return = PErrorT . return . Right
114+ return = pure
115115 (PErrorT m) >>= f = PErrorT $ do
116116 e <- m
117117 case e of
Data/Yaml/Parser.hs+2−2
@@ -36,7 +36,7 @@ newtype YamlParser a = YamlParser
3636instance Functor YamlParser where
3737 fmap = liftM
3838instance Applicative YamlParser where
39− pure = return
39+ pure = YamlParser . const . Right
4040 (<*>) = ap
4141instance Alternative YamlParser where
4242 empty = fail "empty"
@@ -45,7 +45,7 @@ instance Monoid (YamlParser a) where
4545 mempty = fail "mempty"
4646 mappend = mplus
4747instance Monad YamlParser where
48− return = YamlParser . const . Right
48+ return = pure
4949 YamlParser f >>= g = YamlParser $ \am ->
5050 case f am of
5151 Left t -> Left t