summaryrefslogtreecommitdiff
path: root/tests/examples/ghc86/TH_tf1.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/examples/ghc86/TH_tf1.hs')
-rw-r--r--tests/examples/ghc86/TH_tf1.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/examples/ghc86/TH_tf1.hs b/tests/examples/ghc86/TH_tf1.hs
new file mode 100644
index 0000000..2a57097
--- /dev/null
+++ b/tests/examples/ghc86/TH_tf1.hs
@@ -0,0 +1,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
+