diff --git a/Language/Haskell/ParseMonad.hs b/Language/Haskell/ParseMonad.hs index 71db70f..d5d7114 100644 --- a/Language/Haskell/ParseMonad.hs +++ b/Language/Haskell/ParseMonad.hs @@ -27,7 +27,9 @@ module Language.Haskell.ParseMonad( import Language.Haskell.Syntax(SrcLoc(..)) import Control.Applicative +import Control.Monad (ap, liftM) import Data.Monoid +import Prelude -- | The result of a parse. data ParseResult a @@ -111,6 +113,13 @@ runParserWithMode mode (P m) s = case m s 0 1 start [] mode of runParser :: P a -> String -> ParseResult a runParser = runParserWithMode defaultParseMode +instance Functor P where + fmap = liftM + +instance Applicative P where + pure = return + (<*>) = ap + instance Monad P where return a = P $ \_i _x _y _l s _m -> Ok s a P m >>= k = P $ \i x y l s mode -> @@ -156,6 +165,13 @@ popContext = P $ \_i _x _y _l stk _m -> newtype Lex r a = Lex { runL :: (a -> P r) -> P r } +instance Functor (Lex r) where + fmap = liftM + +instance Applicative (Lex r) where + pure = return + (<*>) = ap + instance Monad (Lex r) where return a = Lex $ \k -> k a Lex v >>= f = Lex $ \k -> v (\a -> runL (f a) k) diff --git a/Language/Haskell/Pretty.hs b/Language/Haskell/Pretty.hs index c6df739..f2cae6e 100644 --- a/Language/Haskell/Pretty.hs +++ b/Language/Haskell/Pretty.hs @@ -24,6 +24,9 @@ module Language.Haskell.Pretty ( import Language.Haskell.Syntax +import Control.Applicative (Applicative(..)) +import Control.Monad (ap) + import qualified Text.PrettyPrint as P infixl 5 $$$ @@ -91,6 +94,10 @@ newtype DocM s a = DocM (s -> a) instance Functor (DocM s) where fmap f xs = do x <- xs; return (f x) +instance Applicative (DocM s) where + pure = return + (<*>) = ap + instance Monad (DocM s) where (>>=) = thenDocM (>>) = then_DocM diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..280d98c --- /dev/null +++ b/changelog.md @@ -0,0 +1,6 @@ +# 1.0.2.0 + + - Add support for GHC 7.10 & base-4.8) + + - Add missing `Functor` & `Applicative` instances for `P` and `Lex` + monads needed for AMP compatibility. diff --git a/haskell-src.cabal b/haskell-src.cabal index fd4d5a5..2ae7b66 100644 --- a/haskell-src.cabal +++ b/haskell-src.cabal @@ -1,10 +1,12 @@ name: haskell-src -version: 1.0.1.6 +-- don't forget to update the changelog.md! +version: 1.0.2.0 license: BSD3 license-file: LICENSE author: Simon Marlow, Sven Panne and Noel Winstanley -- Maintained through https://github.com/haskell-pkg-janitors. Join us! -maintainer: Conrad Parker +maintainer: Herbert Valerio Riedel +bug-reports: https://github.com/haskell-pkg-janitors/haskell-src/issues category: Language synopsis: Support for manipulating Haskell source code description: @@ -16,11 +18,13 @@ description: build-type: Simple cabal-version: >=1.6 +extra-source-files: changelog.md + flag split-base source-repository head type: git - location: git://github.com/haskell-pkg-janitors/haskell-src.git + location: https://github.com/haskell-pkg-janitors/haskell-src.git library exposed-modules: @@ -30,10 +34,14 @@ library Language.Haskell.Pretty, Language.Haskell.Syntax, Language.Haskell.ParseUtils + if flag(split-base) build-depends: base >= 4 && < 5, syb, pretty, array else build-depends: base < 3 + + build-tools: happy + extensions: CPP nhc98-options: -K11M ghc-options: -Wall -O2