aboutsummaryrefslogtreecommitdiff
path: root/html-test/src/TypeFamilies.hs
blob: a79d503e7e943a4ea19904d7362e1e03f72f62a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{-# LANGUAGE TypeFamilies, UndecidableInstances, PolyKinds, TypeOperators, DataKinds, MultiParamTypeClasses, GADTs #-}

-- | Doc for: module TypeFamilies
module TypeFamilies where

import qualified TypeFamilies2 as TF

-- | Doc for: data X
data X
  = X   -- ^ Doc for: X
  | XX  -- ^ Doc for: XX
  | XXX -- ^ Doc for: XXX

-- | Doc for: data Y
data Y

-- | Doc for: data Z
data Z = ZA | ZB

-- | 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: type family Foo a
type family Foo a :: k

-- | Doc for: type instance Foo X = Y
type instance Foo X = Y
-- | Doc for: type instance Foo Y = X
type instance Foo Y = X

-- | Doc for: data family Bat a
data family Bat (a :: k) :: *

-- | 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

-- | Doc for: data instance Bat Z
data instance Bat (z :: Z) where
  BatZ1 :: Z -> Bat ZA
  BatZ2 :: { batx :: X, baty :: Y } -> Bat ZB

-- | 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

type family (<>) (a :: k) (b :: k) :: k

type instance X <> a = X
type instance Y <> a = a

type instance XXX <> XX = 'X

class (><) (a :: k) (b :: k)
instance XX >< XXX

-- | External instance

type instance TF.Foo X = Y

data instance TF.Bar Y