Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on Nov 09, 2011
@laughedelic laughedelic names splicing e6920c4
Commits on Jan 04, 2012
@mboes Merge pull request #3 from laughedelic/master
Names splicing functionality
5710f56
Showing with 5 additions and 8 deletions.
  1. +5 −8 Language/Haskell/Exts/QQ.hs
View
13 Language/Haskell/Exts/QQ.hs
@@ -86,23 +86,20 @@ qualify n | ":" <- nameBase n = '(:)
antiquoteExp :: Data a => a -> Q Exp
antiquoteExp t = dataToQa (conE . qualify) litE (foldl appE)
- (const Nothing `extQ` antiE `extQ` antiP) t
+ (const Nothing `extQ` antiE `extQ` antiP `extQ` antiN) t
where antiE (Hs.SpliceExp (Hs.IdSplice v)) = Just $ varE $ mkName v
antiE (Hs.SpliceExp (Hs.ParenSplice e)) = Just $ return $ Hs.toExp e
antiE _ = Nothing
antiP (Hs.PParen (Hs.PParen (Hs.PVar (Hs.Ident n)))) =
Just $ appE [| Hs.PVar |] (varE (mkName n))
antiP _ = Nothing
+ antiN (Hs.Ident ('_':n)) =
+ Just $ (varE (mkName n))
+ antiN _ = Nothing
antiquotePat :: Data a => a -> Q Pat
antiquotePat = dataToQa qualify litP conP (const Nothing `extQ` antiP)
- where antiE (Hs.SpliceExp (Hs.IdSplice v)) = Just $ varP $ mkName v
- antiE (Hs.SpliceExp (Hs.ParenSplice e)) =
- case Hs.parsePat $ Hs.prettyPrint e of
- Hs.ParseOk p -> Just $ return $ Hs.toPat p
- Hs.ParseFailed _ err -> Just $ fail err
- antiE _ = Nothing
- antiP (Hs.PParen (Hs.PParen (Hs.PVar (Hs.Ident n)))) =
+ where antiP (Hs.PParen (Hs.PParen (Hs.PVar (Hs.Ident n)))) =
Just $ conP 'Hs.PVar [varP (mkName n)]
antiP _ = Nothing

No commit comments for this range

Something went wrong with that request. Please try again.