diff options
author | Jan Stolarek <jan.stolarek@p.lodz.pl> | 2015-09-08 19:19:44 +0200 |
---|---|---|
committer | Jan Stolarek <jan.stolarek@p.lodz.pl> | 2015-10-16 20:15:44 +0200 |
commit | 75492e7467ff962f2f2e29e5c8b2c588c94ae8a7 (patch) | |
tree | 8ed0f57f12dbb5c73b0f0d1d1994aef5dd89cea0 /libraries/template-haskell | |
parent | b1884b0e62f62e3c0859515c4137124ab0c9560e (diff) | |
download | haskell-75492e7467ff962f2f2e29e5c8b2c588c94ae8a7.tar.gz |
Add typed holes support in Template Haskell.
Fixes #10267. Typed holes in typed Template Haskell currently don't work.
See #10945 and #10946.
Diffstat (limited to 'libraries/template-haskell')
-rw-r--r-- | libraries/template-haskell/Language/Haskell/TH/Lib.hs | 3 | ||||
-rw-r--r-- | libraries/template-haskell/Language/Haskell/TH/Ppr.hs | 1 | ||||
-rw-r--r-- | libraries/template-haskell/Language/Haskell/TH/Syntax.hs | 4 |
3 files changed, 8 insertions, 0 deletions
diff --git a/libraries/template-haskell/Language/Haskell/TH/Lib.hs b/libraries/template-haskell/Language/Haskell/TH/Lib.hs index fd5dd70802..f38f36fb6f 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Lib.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Lib.hs @@ -300,6 +300,9 @@ fieldExp s e = do { e' <- e; return (s,e') } staticE :: ExpQ -> ExpQ staticE = fmap StaticE +unboundVarE :: Name -> ExpQ +unboundVarE s = return (UnboundVarE s) + -- ** 'arithSeqE' Shortcuts fromE :: ExpQ -> ExpQ fromE x = do { a <- x; return (ArithSeqE (FromR a)) } diff --git a/libraries/template-haskell/Language/Haskell/TH/Ppr.hs b/libraries/template-haskell/Language/Haskell/TH/Ppr.hs index 589382aac3..1768b1550e 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Ppr.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Ppr.hs @@ -172,6 +172,7 @@ pprExp _ (RecConE nm fs) = ppr nm <> braces (pprFields fs) pprExp _ (RecUpdE e fs) = pprExp appPrec e <> braces (pprFields fs) pprExp i (StaticE e) = parensIf (i >= appPrec) $ text "static"<+> pprExp appPrec e +pprExp _ (UnboundVarE v) = pprName' Applied v pprFields :: [(Name,Exp)] -> Doc pprFields = sep . punctuate comma . map (\(s,e) -> ppr s <+> equals <+> ppr e) diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs index 97c379d407..8d56a98dc8 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs @@ -1032,6 +1032,9 @@ mkNameG :: NameSpace -> String -> String -> String -> Name mkNameG ns pkg modu occ = Name (mkOccName occ) (NameG ns (mkPkgName pkg) (mkModName modu)) +mkNameS :: String -> Name +mkNameS n = Name (mkOccName n) NameS + mkNameG_v, mkNameG_tc, mkNameG_d :: String -> String -> String -> Name mkNameG_v = mkNameG VarName mkNameG_tc = mkNameG TcClsName @@ -1415,6 +1418,7 @@ data Exp | RecConE Name [FieldExp] -- ^ @{ T { x = y, z = w } }@ | RecUpdE Exp [FieldExp] -- ^ @{ (f x) { z = w } }@ | StaticE Exp -- ^ @{ static e }@ + | UnboundVarE Name -- ^ @{ _x }@ (hole) deriving( Show, Eq, Ord, Data, Typeable, Generic ) type FieldExp = (Name,Exp) |