blob: 9202c18995287f96023a5504f6c514ac10642e94 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE NamedWildCards #-}
module Splices where
import Language.Haskell.TH
import Language.Haskell.TH.Lib (wildCardT)
metaType1 :: TypeQ
metaType1 = wildCardT
metaType2 :: TypeQ
metaType2 = [t| _ |]
metaType3 :: TypeQ
metaType3 = [t| _ -> _ -> _ |]
metaDec1 :: Q [Dec]
metaDec1 = [d| foo :: _ => _
foo x y = x == y |]
metaDec2 :: Q [Dec]
metaDec2 = [d| bar :: _a -> _b -> (_a, _b)
bar x y = (not x, y) |]
-- An expression with a partial type annotation
metaExp1 :: ExpQ
metaExp1 = [| Just True :: Maybe _ |]
metaExp2 :: ExpQ
metaExp2 = [| id :: _a -> _a |]
|