aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src
diff options
context:
space:
mode:
authorHerbert Valerio Riedel <hvr@gnu.org>2015-12-05 00:29:55 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2015-12-14 15:54:22 +0000
commit3f503bd54678ec9ea611ba81360b573eb745e7b0 (patch)
tree30ca0a1a452915d9f63484397ae20d94decbf2c9 /haddock-api/src
parentf310809a04592f8841583a2e146021d68f9a8432 (diff)
Canonicalise Monad instances
Diffstat (limited to 'haddock-api/src')
-rw-r--r--haddock-api/src/Haddock/Interface/Rename.hs4
-rw-r--r--haddock-api/src/Haddock/Types.hs10
2 files changed, 7 insertions, 7 deletions
diff --git a/haddock-api/src/Haddock/Interface/Rename.hs b/haddock-api/src/Haddock/Interface/Rename.hs
index 4804faff..2183d8f2 100644
--- a/haddock-api/src/Haddock/Interface/Rename.hs
+++ b/haddock-api/src/Haddock/Interface/Rename.hs
@@ -91,13 +91,13 @@ newtype RnM a =
instance Monad RnM where
(>>=) = thenRn
- return = returnRn
+ return = pure
instance Functor RnM where
fmap f x = do a <- x; return (f a)
instance Applicative RnM where
- pure = return
+ pure = returnRn
(<*>) = ap
returnRn :: a -> RnM a
diff --git a/haddock-api/src/Haddock/Types.hs b/haddock-api/src/Haddock/Types.hs
index 9db11be6..e07f55f1 100644
--- a/haddock-api/src/Haddock/Types.hs
+++ b/haddock-api/src/Haddock/Types.hs
@@ -586,11 +586,11 @@ instance Functor ErrMsgM where
fmap f (Writer (a, msgs)) = Writer (f a, msgs)
instance Applicative ErrMsgM where
- pure = return
- (<*>) = ap
+ pure a = Writer (a, [])
+ (<*>) = ap
instance Monad ErrMsgM where
- return a = Writer (a, [])
+ return = pure
m >>= k = Writer $ let
(a, w) = runWriter m
(b, w') = runWriter (k a)
@@ -639,11 +639,11 @@ instance Functor ErrMsgGhc where
fmap f (WriterGhc x) = WriterGhc (fmap (first f) x)
instance Applicative ErrMsgGhc where
- pure = return
+ pure a = WriterGhc (return (a, []))
(<*>) = ap
instance Monad ErrMsgGhc where
- return a = WriterGhc (return (a, []))
+ return = pure
m >>= k = WriterGhc $ runWriterGhc m >>= \ (a, msgs1) ->
fmap (second (msgs1 ++)) (runWriterGhc (k a))