diff options
author | Tim Baumann <tim@timbaumann.info> | 2017-08-06 11:33:38 +0200 |
---|---|---|
committer | Alexander Biehl <alexbiehl@gmail.com> | 2017-08-06 11:33:38 +0200 |
commit | 3fddb62913c72f29843335aa796c2e444ded1608 (patch) | |
tree | a3cccdacd8e546e527488009ebd5d9c815be46d3 /html-test | |
parent | 4d765e3cd0a735f9a7e8d13fb6633f9ee534fbfb (diff) |
Fix: Generate pattern signatures for constructors exported as patterns (#663)
* Fix pretty-printing of pattern signatures
Pattern synonyms can have up to two contexts, both having a
different semantic meaning: The first holds the constraints
required to perform the matching, the second contains the
constraints provided by a successful pattern match. When the
first context is empty but the second is not it is necessary
to render the first, empty context.
* Generate pattern synonym signatures for ctors exported as patterns
This fixes #653.
* Simplify extractPatternSyn
It is not necessary to generate the simplest type signature since
it will be simplified when pretty-printed.
* Add changelog entries for PR #663
* Fix extractPatternSyn error message
Diffstat (limited to 'html-test')
-rw-r--r-- | html-test/ref/ConstructorPatternExport.html | 124 | ||||
-rw-r--r-- | html-test/ref/PatternSyns.html | 76 | ||||
-rw-r--r-- | html-test/src/ConstructorPatternExport.hs | 26 | ||||
-rw-r--r-- | html-test/src/PatternSyns.hs | 8 |
4 files changed, 233 insertions, 1 deletions
diff --git a/html-test/ref/ConstructorPatternExport.html b/html-test/ref/ConstructorPatternExport.html new file mode 100644 index 00000000..20f00d0f --- /dev/null +++ b/html-test/ref/ConstructorPatternExport.html @@ -0,0 +1,124 @@ +<html xmlns="http://www.w3.org/1999/xhtml" +><head + ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" + /><title + >ConstructorPatternExport</title + ><link href="#" rel="stylesheet" type="text/css" title="Ocean" + /><script src="haddock-util.js" type="text/javascript" + ></script + ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript" + ></script + ><script type="text/javascript" + >// +window.onload = function () {pageLoad();}; +// +</script + ></head + ><body + ><div id="package-header" + ><ul class="links" id="page-menu" + ><li + ><a href="#" + >Contents</a + ></li + ><li + ><a href="#" + >Index</a + ></li + ></ul + ><p class="caption empty" + ></p + ></div + ><div id="content" + ><div id="module-header" + ><table class="info" + ><tr + ><th + >Safe Haskell</th + ><td + >Safe</td + ></tr + ></table + ><p class="caption" + >ConstructorPatternExport</p + ></div + ><div id="interface" + ><h1 + >Documentation</h1 + ><div class="top" + ><p class="src" + ><span class="keyword" + >pattern</span + > <a id="v:FooCons" class="def" + >FooCons</a + > :: <a href="#" + >String</a + > -> a -> Foo a <a href="#" class="selflink" + >#</a + ></p + ></div + ><div class="top" + ><p class="src" + ><span class="keyword" + >pattern</span + > <a id="v:MyRecCons" class="def" + >MyRecCons</a + > :: <a href="#" + >Bool</a + > -> <a href="#" + >Int</a + > -> MyRec <a href="#" class="selflink" + >#</a + ></p + ></div + ><div class="top" + ><p class="src" + ><span class="keyword" + >pattern</span + > <a id="v::-43-" class="def" + >(:+)</a + > :: <a href="#" + >String</a + > -> a -> MyInfix a <a href="#" class="selflink" + >#</a + ></p + ></div + ><div class="top" + ><p class="src" + ><span class="keyword" + >pattern</span + > <a id="v:BlubCons" class="def" + >BlubCons</a + > :: () => <a href="#" + >Show</a + > b => b -> Blub <a href="#" class="selflink" + >#</a + ></p + ></div + ><div class="top" + ><p class="src" + ><span class="keyword" + >pattern</span + > <a id="v:MyGADTCons" class="def" + >MyGADTCons</a + > :: () => <span class="keyword" + >forall</span + > a. <a href="#" + >Eq</a + > a => a -> <a href="#" + >Int</a + > -> MyGADT (<a href="#" + >Maybe</a + > <a href="#" + >String</a + >) <a href="#" class="selflink" + >#</a + ></p + ></div + ></div + ></div + ><div id="footer" + ></div + ></body + ></html +>
\ No newline at end of file diff --git a/html-test/ref/PatternSyns.html b/html-test/ref/PatternSyns.html index 2cf936b3..37596645 100644 --- a/html-test/ref/PatternSyns.html +++ b/html-test/ref/PatternSyns.html @@ -101,6 +101,28 @@ window.onload = function () {pageLoad();}; ><li class="src short" ><span class="keyword" >data</span + > <a href="#" + >BlubType</a + > = <a href="#" + >Show</a + > x => <a href="#" + >BlubCtor</a + > x</li + ><li class="src short" + ><span class="keyword" + >pattern</span + > <a href="#" + >Blub</a + > :: () => <span class="keyword" + >forall</span + > x. <a href="#" + >Show</a + > x => x -> <a href="#" + >BlubType</a + ></li + ><li class="src short" + ><span class="keyword" + >data</span > (a :: <a href="#" >*</a >) <a href="#" @@ -237,6 +259,60 @@ window.onload = function () {pageLoad();}; ><p class="src" ><span class="keyword" >data</span + > <a id="t:BlubType" class="def" + >BlubType</a + > <a href="#" class="selflink" + >#</a + ></p + ><div class="doc" + ><p + >BlubType is existentially quantified</p + ></div + ><div class="subs constructors" + ><p class="caption" + >Constructors</p + ><table + ><tr + ><td class="src" + ><a href="#" + >Show</a + > x => <a id="v:BlubCtor" class="def" + >BlubCtor</a + > x</td + ><td class="doc empty" + ></td + ></tr + ></table + ></div + ></div + ><div class="top" + ><p class="src" + ><span class="keyword" + >pattern</span + > <a id="v:Blub" class="def" + >Blub</a + > :: () => <span class="keyword" + >forall</span + > x. <a href="#" + >Show</a + > x => x -> <a href="#" + >BlubType</a + > <a href="#" class="selflink" + >#</a + ></p + ><div class="doc" + ><p + >Pattern synonym for <code + ><a href="#" + >Blub</a + ></code + > x</p + ></div + ></div + ><div class="top" + ><p class="src" + ><span class="keyword" + >data</span > (a :: <a href="#" >*</a >) <a id="t:-62--60-" class="def" 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/PatternSyns.hs b/html-test/src/PatternSyns.hs index a8de113c..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,6 +15,12 @@ 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 |