aboutsummaryrefslogtreecommitdiff
path: root/html-test/src/TypeFamilies.hs
diff options
context:
space:
mode:
authornand <git@nand.wakku.to>2014-02-04 22:13:27 +0100
committerMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-02-11 15:48:30 +0000
commite0718f203f2448ba2029e70d14aed075860b7fac (patch)
treebe0d1a8d69efe1c7114b0740a660dff28939ad69 /html-test/src/TypeFamilies.hs
parent860d6504530a163e7483960ca8837eb596e05634 (diff)
Add support for type/data families
This adds support for type/data families with their respective instances, as well as closed type families and associated type/data families. Signed-off-by: Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>
Diffstat (limited to 'html-test/src/TypeFamilies.hs')
-rw-r--r--html-test/src/TypeFamilies.hs76
1 files changed, 58 insertions, 18 deletions
diff --git a/html-test/src/TypeFamilies.hs b/html-test/src/TypeFamilies.hs
index 561f95fd..725e76a7 100644
--- a/html-test/src/TypeFamilies.hs
+++ b/html-test/src/TypeFamilies.hs
@@ -1,28 +1,68 @@
-{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE TypeFamilies, UndecidableInstances #-}
+-- | Doc for: module TypeFamilies
module TypeFamilies where
--- | Type family G
-type family G a :: *
+-- | Doc for: data X
+data X
+ = X -- ^ Doc for: X
+ | XX -- ^ Doc for: XX
+ | XXX -- ^ Doc for: XXX
--- | A class with an associated type
-class A a where
- -- | An associated type
- data B a :: * -> *
- -- | A method
- f :: B a Int
+-- | Doc for: data Y
+data Y
--- | Doc for family
-type family F a
+-- | Doc for: class Test a
+class Test a
+-- | Doc for: instance Test X
+instance Test X
+-- | Doc for: instance Test Y
+instance Test Y
--- | Doc for G Int
-type instance G Int = Bool
-type instance G Float = Int
+-- | Doc for: type family Foo a
+type family Foo a
+-- | Doc for: type instance Foo X = Y
+type instance Foo X = Y
+-- | Doc for: type instance Foo Y = X
+type instance Foo Y = X
-instance A Int where
- data B Int x = Con x
- f = Con 3
+-- | Doc for: data family Bat a
+data family Bat a :: *
-g = Con 5
+-- | Doc for: data instance Bat X
+data instance Bat X
+ = BatX X -- ^ Doc for: BatX X
+ | BatXX { aaa :: X , bbb :: Y } -- ^ Doc for: BatXX { ... }
+
+-- | Doc for: data instance Bat Y
+data instance Bat Y
+ = BatY Y -- ^ Doc for: BatY Y
+ | X :+ X -- X :+ X
+
+-- | Doc for: class Assoc a
+class Assoc a where
+ -- | Doc for: data AssocD a
+ data AssocD a :: *
+ -- | Doc for: type AssocT a
+ type AssocT a :: *
+
+-- | Doc for: instance Assoc X
+instance Assoc X where
+ -- | Doc for: data AssocD X = AssocX
+ data AssocD X = AssocX -- ^ Doc for: AssocX
+ -- | Doc for: type AssocT X = Foo X
+ type AssocT X = Foo X
+
+-- | Doc for: instance Assoc Y
+instance Assoc Y where
+ -- | Doc for: data AssocD Y = AssocY
+ data AssocD Y = AssocY -- ^ Doc for: AssocY
+ -- | Doc for: type AssocT Y = Bat Y
+ type AssocT Y = Bat Y
+
+-- | Doc for: type family Bar b
+type family Bar b where
+ Bar X = X
+ Bar y = Y