aboutsummaryrefslogtreecommitdiff
path: root/html-test/src
diff options
context:
space:
mode:
authoralexbiehl <alex.biehl@gmail.com>2017-08-21 20:05:42 +0200
committeralexbiehl <alex.biehl@gmail.com>2017-08-21 20:05:42 +0200
commit7a71af839bd71992a36d97650004c73bf11fa436 (patch)
treee64afbc9df5c97fde6ac6433e42f28df8a4acf49 /html-test/src
parentc8a01b83be52e45d3890db173ffe7b09ccd4f351 (diff)
parent740458ac4d2acf197f2ef8dc94a66f9b160b9c3c (diff)
Merge remote-tracking branch 'origin/master' into ghc-head
Diffstat (limited to 'html-test/src')
-rw-r--r--html-test/src/Bug613.hs16
-rw-r--r--html-test/src/Bug647.hs6
-rw-r--r--html-test/src/BundledPatterns.hs110
-rw-r--r--html-test/src/BundledPatterns2.hs10
-rw-r--r--html-test/src/ConstructorPatternExport.hs26
-rw-r--r--html-test/src/DuplicateRecordFields.hs25
-rw-r--r--html-test/src/PR643.hs3
-rw-r--r--html-test/src/PR643_1.hs7
-rw-r--r--html-test/src/PatternSyns.hs13
-rw-r--r--html-test/src/SpuriousSuperclassConstraints.hs2
10 files changed, 216 insertions, 2 deletions
diff --git a/html-test/src/Bug613.hs b/html-test/src/Bug613.hs
new file mode 100644
index 00000000..effef695
--- /dev/null
+++ b/html-test/src/Bug613.hs
@@ -0,0 +1,16 @@
+module Bug613 where
+
+import Prelude (Either(Left, Right))
+
+class Functor f where
+ fmap :: (a -> b) -> f a -> f b
+
+instance Functor (Either a) where
+ fmap _ (Left x) = Left x
+ fmap f (Right y) = Right (f y)
+
+-- | Phantom type a0 is added to block the first renaming from a to a0. This ensures that the renamer doesn't create a new conflict
+data ThreeVars a0 a b = ThreeVars a b
+
+instance Functor (ThreeVars a0 a) where
+ fmap f (ThreeVars a b) = ThreeVars a (f b)
diff --git a/html-test/src/Bug647.hs b/html-test/src/Bug647.hs
new file mode 100644
index 00000000..4143092a
--- /dev/null
+++ b/html-test/src/Bug647.hs
@@ -0,0 +1,6 @@
+module Bug647 where
+
+class Bug647 a where
+ f :: a -- ^ doc for arg1
+ -> a -- ^ doc for arg2
+ -> a -- ^ doc for arg3 \ No newline at end of file
diff --git a/html-test/src/BundledPatterns.hs b/html-test/src/BundledPatterns.hs
new file mode 100644
index 00000000..443e64fa
--- /dev/null
+++ b/html-test/src/BundledPatterns.hs
@@ -0,0 +1,110 @@
+{-# LANGUAGE DataKinds, GADTs, KindSignatures, PatternSynonyms, TypeOperators,
+ ViewPatterns #-}
+module BundledPatterns (Vec(Nil,(:>)), RTree (LR,BR)) where
+
+import GHC.TypeLits
+import Prelude hiding (head, tail)
+import Unsafe.Coerce
+
+-- | Fixed size vectors.
+--
+-- * Lists with their length encoded in their type
+-- * 'Vec'tor elements have an __ASCENDING__ subscript starting from 0 and
+-- ending at @'length' - 1@.
+data Vec :: Nat -> * -> * where
+ Nil :: Vec 0 a
+ Cons :: a -> Vec n a -> Vec (n + 1) a
+
+infixr 5 `Cons`
+
+-- | Add an element to the head of a vector.
+--
+-- >>> 3:>4:>5:>Nil
+-- <3,4,5>
+-- >>> let x = 3:>4:>5:>Nil
+-- >>> :t x
+-- x :: Num a => Vec 3 a
+--
+-- Can be used as a pattern:
+--
+-- >>> let f (x :> y :> _) = x + y
+-- >>> :t f
+-- f :: Num a => Vec ((n + 1) + 1) a -> a
+-- >>> f (3:>4:>5:>6:>7:>Nil)
+-- 7
+--
+-- Also in conjunctions with (':<'):
+--
+-- >>> let g (a :> b :> (_ :< y :< x)) = a + b + x + y
+-- >>> :t g
+-- g :: Num a => Vec ((((n + 1) + 1) + 1) + 1) a -> a
+-- >>> g (1:>2:>3:>4:>5:>Nil)
+-- 12
+pattern (:>) :: a -> Vec n a -> Vec (n + 1) a
+pattern (:>) x xs <- ((\ys -> (head ys,tail ys)) -> (x,xs))
+ where
+ (:>) x xs = Cons x xs
+
+infixr 5 :>
+
+head :: Vec (n + 1) a -> a
+head (x `Cons` _) = x
+
+tail :: Vec (n + 1) a -> Vec n a
+tail (_ `Cons` xs) = unsafeCoerce xs
+
+-- | Perfect depth binary tree.
+--
+-- * Only has elements at the leaf of the tree
+-- * A tree of depth /d/ has /2^d/ elements.
+data RTree :: Nat -> * -> * where
+ LR_ :: a -> RTree 0 a
+ BR_ :: RTree d a -> RTree d a -> RTree (d+1) a
+
+textract :: RTree 0 a -> a
+textract (LR_ x) = x
+{-# NOINLINE textract #-}
+
+tsplit :: RTree (d+1) a -> (RTree d a,RTree d a)
+tsplit (BR_ l r) = (unsafeCoerce l, unsafeCoerce r)
+{-# NOINLINE tsplit #-}
+
+-- | Leaf of a perfect depth tree
+--
+-- >>> LR 1
+-- 1
+-- >>> let x = LR 1
+-- >>> :t x
+-- x :: Num a => RTree 0 a
+--
+-- Can be used as a pattern:
+--
+-- >>> let f (LR a) (LR b) = a + b
+-- >>> :t f
+-- f :: Num a => RTree 0 a -> RTree 0 a -> a
+-- >>> f (LR 1) (LR 2)
+-- 3
+pattern LR :: a -> RTree 0 a
+pattern LR x <- (textract -> x)
+ where
+ LR x = LR_ x
+
+-- | Branch of a perfect depth tree
+--
+-- >>> BR (LR 1) (LR 2)
+-- <1,2>
+-- >>> let x = BR (LR 1) (LR 2)
+-- >>> :t x
+-- x :: Num a => RTree 1 a
+--
+-- Case be used a pattern:
+--
+-- >>> let f (BR (LR a) (LR b)) = LR (a + b)
+-- >>> :t f
+-- f :: Num a => RTree 1 a -> RTree 0 a
+-- >>> f (BR (LR 1) (LR 2))
+-- 3
+pattern BR :: RTree d a -> RTree d a -> RTree (d+1) a
+pattern BR l r <- ((\t -> (tsplit t)) -> (l,r))
+ where
+ BR l r = BR_ l r
diff --git a/html-test/src/BundledPatterns2.hs b/html-test/src/BundledPatterns2.hs
new file mode 100644
index 00000000..5e9a83a7
--- /dev/null
+++ b/html-test/src/BundledPatterns2.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE DataKinds, GADTs, KindSignatures, PatternSynonyms, TypeOperators,
+ ViewPatterns #-}
+module BundledPatterns2 (Vec((:>), Empty), RTree(..)) where
+
+import GHC.TypeLits
+
+import BundledPatterns
+
+pattern Empty :: Vec 0 a
+pattern Empty <- Nil
diff --git a/html-test/src/ConstructorPatternExport.hs b/html-test/src/ConstructorPatternExport.hs
new file mode 100644
index 00000000..7897b4bc
--- /dev/null
+++ b/html-test/src/ConstructorPatternExport.hs
@@ -0,0 +1,26 @@
+{-# LANGUAGE PatternSynonyms #-}
+{-# LANGUAGE ExistentialQuantification #-}
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE KindSignatures #-}
+
+module ConstructorPatternExport (
+ pattern FooCons
+ , pattern MyRecCons
+ , pattern (:+)
+ , pattern BlubCons
+ , pattern MyGADTCons
+ ) where
+
+data Foo a = FooCons String a
+
+data MyRec = MyRecCons { one :: Bool, two :: Int }
+
+data MyInfix a = String :+ a
+
+data Blub = forall b. Show b => BlubCons b
+
+data MyGADT :: * -> * where
+ MyGADTCons :: forall a. Eq a => a -> Int -> MyGADT (Maybe String)
+
+pattern MyGADTCons' :: () => forall a. Eq a => a -> Int -> MyGADT (Maybe String)
+pattern MyGADTCons' x y = MyGADTCons x y \ No newline at end of file
diff --git a/html-test/src/DuplicateRecordFields.hs b/html-test/src/DuplicateRecordFields.hs
new file mode 100644
index 00000000..2cf9ff43
--- /dev/null
+++ b/html-test/src/DuplicateRecordFields.hs
@@ -0,0 +1,25 @@
+{-# LANGUAGE DuplicateRecordFields #-}
+module DuplicateRecordFields (RawReplay(..)) where
+
+import Prelude hiding (Int)
+
+data Int = Int
+
+data RawReplay = RawReplay
+ { headerSize :: Int
+ -- ^ The byte size of the first section.
+ , headerCRC :: Int
+ -- ^ The CRC of the first section.
+ , header :: Int
+ -- ^ The first section.
+ , contentSize :: Int
+ -- ^ The byte size of the second section.
+ , contentCRC :: Int
+ -- ^ The CRC of the second section.
+ , content :: Int
+ -- ^ The second section.
+ , footer :: Int
+ -- ^ Arbitrary data after the second section. In replays generated by
+ -- Rocket League, this is always empty. However it is not technically
+ -- invalid to put something here.
+ } \ No newline at end of file
diff --git a/html-test/src/PR643.hs b/html-test/src/PR643.hs
new file mode 100644
index 00000000..565e5b57
--- /dev/null
+++ b/html-test/src/PR643.hs
@@ -0,0 +1,3 @@
+module PR643 (test) where
+
+import PR643_1
diff --git a/html-test/src/PR643_1.hs b/html-test/src/PR643_1.hs
new file mode 100644
index 00000000..ecd0db94
--- /dev/null
+++ b/html-test/src/PR643_1.hs
@@ -0,0 +1,7 @@
+module PR643_1 where
+
+infixr 5 `test`
+
+-- | Some big documentation
+test :: ()
+test = ()
diff --git a/html-test/src/PatternSyns.hs b/html-test/src/PatternSyns.hs
index 8af5eb23..bf0f7848 100644
--- a/html-test/src/PatternSyns.hs
+++ b/html-test/src/PatternSyns.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE PatternSynonyms, PolyKinds, TypeOperators #-}
+{-# LANGUAGE ExistentialQuantification, PatternSynonyms, PolyKinds, TypeOperators #-}
-- | Testing some pattern synonyms
module PatternSyns where
@@ -15,8 +15,19 @@ pattern Bar x = FooCtor (Foo x)
-- | Pattern synonym for (':<->')
pattern x :<-> y = (Foo x, Bar y)
+-- | BlubType is existentially quantified
+data BlubType = forall x. Show x => BlubCtor x
+
+-- | Pattern synonym for 'Blub' x
+pattern Blub x = BlubCtor x
+
-- | Doc for ('><')
data (a :: *) >< b = Empty
-- | Pattern for 'Empty'
pattern E = Empty
+
+-- | Earlier ghc versions didn't allow explicit signatures
+-- on pattern synonyms.
+pattern PatWithExplicitSig :: Eq somex => somex -> FooType somex
+pattern PatWithExplicitSig x = FooCtor x
diff --git a/html-test/src/SpuriousSuperclassConstraints.hs b/html-test/src/SpuriousSuperclassConstraints.hs
index d9e43e1c..3e230945 100644
--- a/html-test/src/SpuriousSuperclassConstraints.hs
+++ b/html-test/src/SpuriousSuperclassConstraints.hs
@@ -7,7 +7,7 @@
--
-- <http://www.haskell.org/pipermail/haskell-cafe/2012-September/103600.html>
--
--- And here is the corresponding theard on glasgow-haskell-users:
+-- And here is the corresponding thread on glasgow-haskell-users:
--
-- <http://www.haskell.org/pipermail/glasgow-haskell-users/2012-September/022914.html>
--