diff options
Diffstat (limited to 'src/Haddock/Types.hs')
-rw-r--r-- | src/Haddock/Types.hs | 16 |
1 files changed, 13 insertions, 3 deletions
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) |