From 87c551fc668b9251f2647cce8772f205e1cee154 Mon Sep 17 00:00:00 2001 From: Christiaan Baaij Date: Fri, 9 Jun 2017 08:26:43 +0200 Subject: Haddock support for bundled pattern synonyms (#627) * Haddock support for bundled pattern synonyms * Add fixities to bundled pattern synonyms * Add bundled pattern synonyms to the synopsis * Store bundled pattern fixities in expItemFixities * Add test for bundled pattern synonyms * Stop threading fixities * Include bundled pattern synonyms for re-exported data types Sadly, fixity information isn't found for re-exported data types * Support for pattern synonyms * Modify tests after #631 * Test some reexport variations * Also lookup bundled pattern synonyms from `InstalledInterface`s * Check isExported for bundled pattern synonyms * Pattern synonym is exported check * Always look for pattern synonyms in the current module Another overlooked cornercase * Account for types named twice in export lists Also introduce a fast function for nubbing on a `Name` and use it throughout the code base. * correct fixities for reexported pattern synonyms * Fuse concatMap and map * Remove obsolete import * Add pattern synonyms to visible exports * Fix test * Remove corner case --- html-test/ref/BundledPatterns.html | 474 ++++++++++++++++++++++++++++++++++++ html-test/ref/BundledPatterns2.html | 472 +++++++++++++++++++++++++++++++++++ 2 files changed, 946 insertions(+) create mode 100644 html-test/ref/BundledPatterns.html create mode 100644 html-test/ref/BundledPatterns2.html (limited to 'html-test/ref') diff --git a/html-test/ref/BundledPatterns.html b/html-test/ref/BundledPatterns.html new file mode 100644 index 00000000..bf6c073c --- /dev/null +++ b/html-test/ref/BundledPatterns.html @@ -0,0 +1,474 @@ +BundledPatterns

Safe HaskellNone

BundledPatterns

Synopsis

Documentation

data Vec :: Nat -> * -> * where #

Fixed size vectors.

  • Lists with their length encoded in their type
  • Vector elements have an ASCENDING subscript starting from 0 and + ending at length - 1.

Constructors

Nil :: Vec 0 a

Bundled Patterns

pattern (:>) :: a -> Vec n a -> Vec (n + 1) a infixr 5

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
+

data RTree :: Nat -> * -> * where #

Perfect depth binary tree.

  • Only has elements at the leaf of the tree
  • A tree of depth d has 2^d elements.

Bundled Patterns

pattern LR :: a -> RTree 0 a

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 BR :: RTree d a -> RTree d a -> RTree (d + 1) a

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
+
\ No newline at end of file diff --git a/html-test/ref/BundledPatterns2.html b/html-test/ref/BundledPatterns2.html new file mode 100644 index 00000000..3d1d4da0 --- /dev/null +++ b/html-test/ref/BundledPatterns2.html @@ -0,0 +1,472 @@ +BundledPatterns2

Safe HaskellNone

BundledPatterns2

Synopsis

Documentation

data Vec :: Nat -> * -> * where #

Fixed size vectors.

  • Lists with their length encoded in their type
  • Vector elements have an ASCENDING subscript starting from 0 and + ending at length - 1.

Bundled Patterns

pattern Empty :: Vec 0 a
pattern (:>) :: a -> Vec n a -> Vec (n + 1) a infixr 5

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
+

data RTree :: Nat -> * -> * where #

Perfect depth binary tree.

  • Only has elements at the leaf of the tree
  • A tree of depth d has 2^d elements.

Bundled Patterns

pattern LR :: a -> RTree 0 a

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 BR :: RTree d a -> RTree d a -> RTree (d + 1) a

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
+
\ No newline at end of file -- cgit v1.2.3