aboutsummaryrefslogtreecommitdiff
path: root/html-test/src/ConstructorArgs.hs
blob: c3b848c39b5bf7fcf652c2f20fec5a9b4e7bf1bd (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
{-# LANGUAGE Haskell2010 #-}
{-# LANGUAGE GADTs, PatternSynonyms #-}

module ConstructorArgs (Foo(..), Boo(Foo, Foa, Fo, Fo'), pattern Bo, pattern Bo') where

data Foo
  = Rec             -- ^ doc on a record
     { x :: String  -- ^ doc on the `String` field of `Rec`
     , y :: String  -- ^ doc on the `String` field of `Rec`
     }
   | Baz Int String  -- ^ old prefix doc style
   | Boa             -- ^ doc on the `Boa` constrictor
       !Int          -- ^ doc on the `Int` field of `Boa`
       !String       -- ^ doc on the `String` field of `Boa`
   | Int :| String   -- ^ old infix doc style
   | Int             -- ^ doc on the `Int` field of the `:*` constructor
       :*            -- ^ doc on the `:*` constructor
     String          -- ^ doc on the `String` field of the `:*` constructor

infixr 1 `Foo`
infixr 2 `Boa`
infixr 3 :*

data Boo where
  -- | Info about a 'Foo'
  Foo :: Int    -- ^ `Int` field of `Foo`
      -> String -- ^ `String` field of `Foo`
      -> Boo    -- ^ Make a `Boo`

  -- | no argument docs GADT
  Foa :: Int -> Boo

infixr 4 `Boo`

-- | Info about bundled 'Fo'
pattern Fo :: Int    -- ^ an 'Int'
           -> String -- ^ a 'String'
           -> Boo    -- ^ a 'Boo'
pattern Fo x y = Foo x y

-- | Bundled and no argument docs
pattern Fo' :: Boo
pattern Fo' = Foo 1 "hi"

infixr 5 `Fo`

-- | Info about not-bundled 'Bo'
pattern Bo :: Int    -- ^ an 'Int'
           -> String -- ^ a 'String'
           -> Boo -- ^ a 'Boo' pattern
pattern Bo x y = Foo x y

-- | Not bunded and no argument docs
pattern Bo' :: Int -> String -> Boo
pattern Bo' x y = Foo x y

infixr 6 `Bo`