summaryrefslogtreecommitdiff
path: root/tests/examples/ghc86/TH_tf1.hs
blob: 2a570979652e3de16553a90748096698bd12ca70 (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 #-}
{-# LANGUAGE TemplateHaskell #-}

module TH_tf1 where

$( [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 :: * -> *) :: * -> * |] )
$( [d| type instance R Maybe = [] |] )

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