X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fparser%2FHaddockParse.y;h=8a46bea82a583cee12807cf4713808c7ce98c91d;hb=24d49415d2833a1338dfb5fd8c5c1c84df6c282b;hp=e23b4ee3c9f51e0d5760892379fecc63d6b49224;hpb=c6b0a84d8a3aec97086e5316b321dad9594a4fac;p=ghc-hetmet.git diff --git a/compiler/parser/HaddockParse.y b/compiler/parser/HaddockParse.y index e23b4ee..8a46bea 100644 --- a/compiler/parser/HaddockParse.y +++ b/compiler/parser/HaddockParse.y @@ -1,12 +1,16 @@ { -{-# OPTIONS -w #-} +{-# OPTIONS -Wwarn -w #-} -- The above warning supression flag is a temporary kludge. -- While working on this module you are encouraged to remove it and fix -- any warnings in the module. See -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings -- for details -module HaddockParse (parseHaddockParagraphs, parseHaddockString) where +module HaddockParse ( + parseHaddockParagraphs, + parseHaddockString, + EitherString(..) +) where import {-# SOURCE #-} HaddockLex import HsSyn @@ -31,7 +35,7 @@ import RdrName PARA { TokPara } STRING { TokString $$ } -%monad { Either String } +%monad { EitherString } %name parseHaddockParagraphs doc %name parseHaddockString seq @@ -94,16 +98,20 @@ strings :: { String } | STRING strings { $1 ++ $2 } { -happyError :: [Token] -> Either String a -happyError toks = --- Left ("parse error in doc string: " ++ show (take 3 toks)) - Left ("parse error in doc string") - --- Either monad (we can't use MonadError because GHC < 5.00 has --- an older incompatible version). -instance Monad (Either String) where - return = Right - Left l >>= _ = Left l - Right r >>= k = k r - fail msg = Left msg +happyError :: [Token] -> EitherString a +happyError toks = MyLeft ("parse error in doc string") + +-- We don't want to make an instance for Either String, +-- since every user of the GHC API would get that instance + +-- But why use non-Haskell98 instances when MyEither String +-- is the only MyEither we're intending to use anyway? --Isaac Dupree +--data MyEither a b = MyLeft a | MyRight b +data EitherString b = MyLeft String | MyRight b + +instance Monad EitherString where + return = MyRight + MyLeft l >>= _ = MyLeft l + MyRight r >>= k = k r + fail msg = MyLeft msg }