Commit 6b2cf62b authored by simonpj@microsoft.com's avatar simonpj@microsoft.com

Allow $x, as well as $(x), at top level in TH

Bulat pointed out that in Template Haskell
   $x
is allowed instead of 
   $(x)
in expressions, but not at the top level of modules.

This commit fixes the omission.  Now you can say

	f x = x
 	$h
	data T = T

and the $h will run Template Haskell just as you'd expect.
parent f7f06be1
......@@ -439,9 +439,14 @@ topdecl :: { OrdList (LHsDecl RdrName) }
| 'foreign' fdecl { unitOL (LL (unLoc $2)) }
| '{-# DEPRECATED' deprecations '#-}' { $2 }
| '{-# RULES' rules '#-}' { $2 }
| '$(' exp ')' { unitOL (LL $ SpliceD (SpliceDecl $2)) }
| decl { unLoc $1 }
-- Template Haskell Extension
| '$(' exp ')' { unitOL (LL $ SpliceD (SpliceDecl $2)) }
| TH_ID_SPLICE { unitOL (LL $ SpliceD (SpliceDecl $
L1 $ HsVar (mkUnqual varName (getTH_ID_SPLICE $1))
)) }
tycl_decl :: { LTyClDecl RdrName }
: 'type' type '=' ctype
-- Note type on the left of the '='; this allows
......@@ -1099,7 +1104,7 @@ aexp2 :: { LHsExpr RdrName }
| '(' qopm infixexp ')' { LL $ SectionR $2 $3 }
| '_' { L1 EWildPat }
-- MetaHaskell Extension
-- Template Haskell Extension
| TH_ID_SPLICE { L1 $ HsSpliceE (mkHsSplice
(L1 $ HsVar (mkUnqual varName
(getTH_ID_SPLICE $1)))) } -- $x
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment