blob: 2b5d3f8887fdf0337de4cf3de434408bacf56c7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
{-# LANGUAGE TypeFamilies #-}
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
|