Skip to content

Commit 24452f1

Browse files
committed
Add support for GHC 7.10 & base-4.8
This add missing `Functor` & `Applicative` instances for `P` and `Lex` (and `DocM`) monads needed for AMP compatibility. The package version is minor-bumped to v1.0.2.0 since new instances were added to the exposed API. Moreover, a Hackage-compliant changelog file is added as extra-source-files.
1 parent 3b57094 commit 24452f1

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

Language/Haskell/ParseMonad.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ module Language.Haskell.ParseMonad(
2727

2828
import Language.Haskell.Syntax(SrcLoc(..))
2929
import Control.Applicative
30+
import Control.Monad (ap, liftM)
3031
import Data.Monoid
32+
import Prelude
3133

3234
-- | The result of a parse.
3335
data ParseResult a
@@ -111,6 +113,13 @@ runParserWithMode mode (P m) s = case m s 0 1 start [] mode of
111113
runParser :: P a -> String -> ParseResult a
112114
runParser = runParserWithMode defaultParseMode
113115

116+
instance Functor P where
117+
fmap = liftM
118+
119+
instance Applicative P where
120+
pure = return
121+
(<*>) = ap
122+
114123
instance Monad P where
115124
return a = P $ \_i _x _y _l s _m -> Ok s a
116125
P m >>= k = P $ \i x y l s mode ->
@@ -156,6 +165,13 @@ popContext = P $ \_i _x _y _l stk _m ->
156165

157166
newtype Lex r a = Lex { runL :: (a -> P r) -> P r }
158167

168+
instance Functor (Lex r) where
169+
fmap = liftM
170+
171+
instance Applicative (Lex r) where
172+
pure = return
173+
(<*>) = ap
174+
159175
instance Monad (Lex r) where
160176
return a = Lex $ \k -> k a
161177
Lex v >>= f = Lex $ \k -> v (\a -> runL (f a) k)

Language/Haskell/Pretty.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ module Language.Haskell.Pretty (
2424

2525
import Language.Haskell.Syntax
2626

27+
import Control.Applicative (Applicative(..))
28+
import Control.Monad (ap)
29+
2730
import qualified Text.PrettyPrint as P
2831

2932
infixl 5 $$$
@@ -91,6 +94,10 @@ newtype DocM s a = DocM (s -> a)
9194
instance Functor (DocM s) where
9295
fmap f xs = do x <- xs; return (f x)
9396

97+
instance Applicative (DocM s) where
98+
pure = return
99+
(<*>) = ap
100+
94101
instance Monad (DocM s) where
95102
(>>=) = thenDocM
96103
(>>) = then_DocM

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# 1.0.2.0
2+
3+
- Add support for GHC 7.10 & base-4.8)
4+
5+
- Add missing `Functor` & `Applicative` instances for `P` and `Lex`
6+
monads needed for AMP compatibility.

haskell-src.cabal

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
name: haskell-src
2-
version: 1.0.1.6
2+
-- don't forget to update the changelog.md!
3+
version: 1.0.2.0
34
license: BSD3
45
license-file: LICENSE
56
author: Simon Marlow, Sven Panne and Noel Winstanley
67
-- Maintained through https://github.com/haskell-pkg-janitors. Join us!
7-
maintainer: Conrad Parker <[email protected]>
8+
maintainer: Herbert Valerio Riedel <[email protected]>
9+
bug-reports: https://github.com/haskell-pkg-janitors/haskell-src/issues
810
category: Language
911
synopsis: Support for manipulating Haskell source code
1012
description:
@@ -16,11 +18,13 @@ description:
1618
build-type: Simple
1719
cabal-version: >=1.6
1820

21+
extra-source-files: changelog.md
22+
1923
flag split-base
2024

2125
source-repository head
2226
type: git
23-
location: git://github.com/haskell-pkg-janitors/haskell-src.git
27+
location: https://github.com/haskell-pkg-janitors/haskell-src.git
2428

2529
library
2630
exposed-modules:
@@ -30,10 +34,14 @@ library
3034
Language.Haskell.Pretty,
3135
Language.Haskell.Syntax,
3236
Language.Haskell.ParseUtils
37+
3338
if flag(split-base)
3439
build-depends: base >= 4 && < 5, syb, pretty, array
3540
else
3641
build-depends: base < 3
42+
43+
build-tools: happy
44+
3745
extensions: CPP
3846
nhc98-options: -K11M
3947
ghc-options: -Wall -O2

0 commit comments

Comments
 (0)