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 /compiler/deSugar/DsMeta.hs | |
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 'compiler/deSugar/DsMeta.hs')
-rw-r--r-- | compiler/deSugar/DsMeta.hs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs index 4c060de29f..df2eaf2846 100644 --- a/compiler/deSugar/DsMeta.hs +++ b/compiler/deSugar/DsMeta.hs @@ -1167,6 +1167,11 @@ repE (ArithSeq _ _ aseq) = repE (HsSpliceE splice) = repSplice splice repE (HsStatic e) = repLE e >>= rep2 staticEName . (:[]) . unC +repE (HsUnboundVar name) = do + occ <- occNameLit name + sname <- repNameS occ + repUnboundVar sname + repE e@(PArrSeq {}) = notHandled "Parallel arrays" (ppr e) repE e@(HsCoreAnn {}) = notHandled "Core annotations" (ppr e) repE e@(HsSCC {}) = notHandled "Cost centres" (ppr e) @@ -1572,10 +1577,10 @@ globalVar name | isExternalName name = do { MkC mod <- coreStringLit name_mod ; MkC pkg <- coreStringLit name_pkg - ; MkC occ <- occNameLit name + ; MkC occ <- nameLit name ; rep2 mk_varg [pkg,mod,occ] } | otherwise - = do { MkC occ <- occNameLit name + = do { MkC occ <- nameLit name ; MkC uni <- coreIntLit (getKey (getUnique name)) ; rep2 mkNameLName [occ,uni] } where @@ -1612,13 +1617,16 @@ wrapGenSyms binds body@(MkC b) go _ [] = return body go var_ty ((name,id) : binds) = do { MkC body' <- go var_ty binds - ; lit_str <- occNameLit name + ; lit_str <- nameLit name ; gensym_app <- repGensym lit_str ; repBindQ var_ty elt_ty gensym_app (MkC (Lam id body')) } -occNameLit :: Name -> DsM (Core String) -occNameLit n = coreStringLit (occNameString (nameOccName n)) +nameLit :: Name -> DsM (Core String) +nameLit n = coreStringLit (occNameString (nameOccName n)) + +occNameLit :: OccName -> DsM (Core String) +occNameLit name = coreStringLit (occNameString name) -- %********************************************************************* @@ -2136,6 +2144,9 @@ mk_lit (HsIntegral _ i) = mk_integer i mk_lit (HsFractional f) = mk_rational f mk_lit (HsIsString _ s) = mk_string s +repNameS :: Core String -> DsM (Core TH.Name) +repNameS (MkC name) = rep2 mkNameSName [name] + --------------- Miscellaneous ------------------- repGensym :: Core String -> DsM (Core (TH.Q TH.Name)) @@ -2150,6 +2161,9 @@ repSequenceQ :: Type -> Core [TH.Q a] -> DsM (Core (TH.Q [a])) repSequenceQ ty_a (MkC list) = rep2 sequenceQName [Type ty_a, list] +repUnboundVar :: Core TH.Name -> DsM (Core TH.ExpQ) +repUnboundVar (MkC name) = rep2 unboundVarEName [name] + ------------ Lists ------------------- -- turn a list of patterns into a single pattern matching a list |