summaryrefslogtreecommitdiff
path: root/testsuite/tests/th/TH_tf1.hs
blob: 43ac2d33797882131a5a369bfed1ea8e472c0644 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{-# LANGUAGE TypeFamilies #-}

module TH_tf1 where

import Data.Kind (Type)

$( [d| data family T a |] )
$( [d| data instance T Int = TInt Bool |] )

foo :: Bool -> T Int
foo b = TInt (b && b)

$( [d| type family S a |] )
$( [d| type instance S Int = Bool |] )

bar :: S Int -> Int
bar c = if c then 1 else 2

$( [d| type family R (a :: Type -> Type) :: Type -> Type |] )
$( [d| type instance R Maybe = [] |] )

baz :: R Maybe Int -> Int
baz = head