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

35 lines
486 B
Haskell
Raw Normal View History

2024-02-25 07:05:53 +00:00
{-# 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)
-- -}