playground/haskell/template-haskell/staging-restriction/THEg.hs

35 lines
486 B
Haskell
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH
import TH
x :: Int
x = 42
$someSplice
z :: String
z = show x
-- import Language.Haskell.TH
-- import Language.Haskell.TH.Syntax
-- someSplice :: Q [Dec]
-- someSplice = [d| y = 0 |]
-- -- $(someSplice)
-- {-
-- GHC stage restriction:
-- someSplice is used in a top-level splice, quasi-quote, or annotation,
-- and must be imported, not defined locally
-- |
-- 9 | $(someSplice)
-- -}