on master help sign in
Merge pull request #76 from hvr/pr/canonical-monad-instances
1cc39a8Michael Snoyman
Data/Yaml/Internal.hs+2−2
@@ -108,10 +108,10 @@ newtype PErrorT m a = PErrorT { runPErrorT :: m (Either ParseException a) }
108instance Monad m => Functor (PErrorT m) where
108instance Monad m => Functor (PErrorT m) where
109 fmap = liftM
109 fmap = liftM
110instance Monad m => Applicative (PErrorT m) where
110instance Monad m => Applicative (PErrorT m) where
111− pure = return
111+ pure = PErrorT . return . Right
112 (<*>) = ap
112 (<*>) = ap
113instance Monad m => Monad (PErrorT m) where
113instance Monad m => Monad (PErrorT m) where
114− return = PErrorT . return . Right
114+ return = pure
115 (PErrorT m) >>= f = PErrorT $ do
115 (PErrorT m) >>= f = PErrorT $ do
116 e <- m
116 e <- m
117 case e of
117 case e of
Data/Yaml/Parser.hs+2−2
@@ -36,7 +36,7 @@ newtype YamlParser a = YamlParser
36instance Functor YamlParser where
36instance Functor YamlParser where
37 fmap = liftM
37 fmap = liftM
38instance Applicative YamlParser where
38instance Applicative YamlParser where
39− pure = return
39+ pure = YamlParser . const . Right
40 (<*>) = ap
40 (<*>) = ap
41instance Alternative YamlParser where
41instance Alternative YamlParser where
42 empty = fail "empty"
42 empty = fail "empty"
@@ -45,7 +45,7 @@ instance Monoid (YamlParser a) where
45 mempty = fail "mempty"
45 mempty = fail "mempty"
46 mappend = mplus
46 mappend = mplus
47instance Monad YamlParser where
47instance Monad YamlParser where
48− return = YamlParser . const . Right
48+ return = pure
49 YamlParser f >>= g = YamlParser $ \am ->
49 YamlParser f >>= g = YamlParser $ \am ->
50 case f am of
50 case f am of
51 Left t -> Left t
51 Left t -> Left t