Skip to content

Commit

Permalink
Compatibility with (at least) GHC 6.12.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bmillwood committed Dec 21, 2010
1 parent d0daad3 commit 85019ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions Control/Applicative/QQ/ADo.hs
Expand Up @@ -27,6 +27,7 @@ import Language.Haskell.TH.Lib
import Language.Haskell.TH.Quote
import Language.Haskell.TH.Syntax
import Control.Monad
import Data.Data (cast, gmapQ)

-- $desugaring
--
Expand Down Expand Up @@ -121,22 +122,24 @@ applicate rawPatterns stmt = do
es

failingPattern :: Pat -> Q Bool
failingPattern p = case p of
failingPattern pat = case pat of
LitP {} -> return True
VarP {} -> return False
TupP ps -> anyFailing ps
ConP n ps -> liftM2 ((||) . not) (singleCon n) (anyFailing ps)
InfixP p n q -> failingPattern $ ConP n [p, q]
TildeP {} -> return False
BangP p -> failingPattern p
AsP _ p -> failingPattern p
WildP -> return False
RecP n fps -> failingPattern $ ConP n (map snd fps)
ListP {} -> return True
SigP p _ -> failingPattern p
ViewP _ p -> failingPattern p
-- recurse on any subpatterns
-- we do this implicitly because it avoids referring to the constructors
-- by name, which means we can work with TH versions where they didn't
-- exist
_ -> fmap or . sequence $ gmapQ (mkQ (return False) failingPattern) pat
where
anyFailing = fmap or . mapM failingPattern
mkQ d f x = maybe d f (cast x)

singleCon :: Name -> Q Bool
singleCon n = do
Expand Down
4 changes: 2 additions & 2 deletions applicative-quoters.cabal
Expand Up @@ -17,7 +17,7 @@ License: BSD3
License-file: LICENSE

Build-type: Simple
Tested-with: GHC == 7.0.1
Tested-with: GHC == 6.12.3, GHC == 7.0.1

Library
Exposed-modules:
Expand All @@ -27,7 +27,7 @@ Library
Build-depends:
base >= 4 && < 4.4,
haskell-src-meta >= 0.2 && < 0.4,
template-haskell == 2.5.*
template-haskell >= 2.4 && < 2.6

GHC-options: -Wall

Expand Down

0 comments on commit 85019ba

Please sign in to comment.