blob: 2237aba6513b4cec947b54cf3d14654e7a06b764 (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
{-# LANGUAGE TemplateHaskell, TypeFamilies, PolyKinds, TypeApplications #-}
module ClosedFam2 where
import Language.Haskell.TH
$( return [ ClosedTypeFamilyD
(TypeFamilyHead
(mkName "Equals")
[ KindedTV (mkName "a") (VarT (mkName "k"))
, KindedTV (mkName "b") (VarT (mkName "k")) ]
( TyVarSig (KindedTV (mkName "r") (VarT (mkName "k"))))
Nothing)
[ TySynEqn Nothing
(AppT (AppT (ConT (mkName "Equals")) (VarT (mkName "a")))
(VarT (mkName "a")))
(ConT (mkName "Int"))
, TySynEqn Nothing
(AppT (AppT (ConT (mkName "Equals")) (VarT (mkName "a")))
(VarT (mkName "b")))
(ConT (mkName "Bool")) ] ])
a :: Equals b b
a = (5 :: Int)
b :: Equals Int Bool
b = False
$( return [ ClosedTypeFamilyD
(TypeFamilyHead
(mkName "Foo")
[ KindedTV (mkName "a") (VarT (mkName "k"))]
(KindSig StarT ) Nothing )
[ TySynEqn Nothing
(AppT (AppKindT (ConT (mkName "Foo")) StarT)
(VarT (mkName "a")))
(ConT (mkName "Int"))
, TySynEqn Nothing
(AppT (AppKindT (ConT (mkName "Foo")) (AppT (AppT ArrowT StarT) (StarT)))
(VarT (mkName "a")))
(ConT (mkName "Bool")) ] ])
c :: Foo Int
c = 5
d :: Foo Bool
d = 6
e :: Foo Maybe
e = False
|