diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Haddock/Interface.hs | 1 | ||||
-rw-r--r-- | src/Haddock/Interface/Create.hs | 2 | ||||
-rw-r--r-- | src/Haddock/Interface/Rename.hs | 1 | ||||
-rw-r--r-- | src/Haddock/Types.hs | 16 |
4 files changed, 14 insertions, 6 deletions
diff --git a/src/Haddock/Interface.hs b/src/Haddock/Interface.hs index 4b178bf4..5f40422e 100644 --- a/src/Haddock/Interface.hs +++ b/src/Haddock/Interface.hs @@ -24,7 +24,6 @@ import Haddock.GHC.Utils import qualified Data.Map as Map import Data.Map (Map) import Data.List -import Control.Monad.Writer import Control.Monad import Name diff --git a/src/Haddock/Interface/Create.hs b/src/Haddock/Interface/Create.hs index 800f099e..24db83b9 100644 --- a/src/Haddock/Interface/Create.hs +++ b/src/Haddock/Interface/Create.hs @@ -19,7 +19,7 @@ import Data.List import Data.Maybe import Data.Char import Data.Ord -import Control.Monad.Writer +import Control.Monad import GHC import Outputable diff --git a/src/Haddock/Interface/Rename.hs b/src/Haddock/Interface/Rename.hs index 2c231960..81717716 100644 --- a/src/Haddock/Interface/Rename.hs +++ b/src/Haddock/Interface/Rename.hs @@ -26,7 +26,6 @@ import Prelude hiding (mapM) import Data.Traversable (mapM) import Control.Arrow import Control.Monad hiding (mapM) -import Control.Monad.Writer hiding (mapM) renameInterface :: LinkEnv -> Interface -> ErrMsgM Interface diff --git a/src/Haddock/Types.hs b/src/Haddock/Types.hs index 6143ae02..f1e01459 100644 --- a/src/Haddock/Types.hs +++ b/src/Haddock/Types.hs @@ -10,7 +10,6 @@ module Haddock.Types where import Data.Map (Map) import qualified Data.Map as Map -import Control.Monad.Writer import GHC hiding (NoLink) import Outputable @@ -203,7 +202,18 @@ data DocMarkup id a = Markup { } --- A monad which collects error messages +-- A monad which collects error messages, locally defined to avoid a dep on mtl type ErrMsg = String -type ErrMsgM a = Writer [ErrMsg] a + +newtype ErrMsgM a = Writer { runWriter :: (a, [ErrMsg]) } + +instance Monad ErrMsgM where + return a = Writer (a, []) + m >>= k = Writer $ let + (a, w) = runWriter m + (b, w') = runWriter (k a) + in (b, w ++ w') + +tell :: [ErrMsg] -> ErrMsgM () +tell w = Writer ((), w) |