diff options
author | Alec Theriault <alec.theriault@gmail.com> | 2018-07-20 03:01:16 -0700 |
---|---|---|
committer | Alexander Biehl <alexbiehl@gmail.com> | 2018-07-20 12:01:16 +0200 |
commit | 953e3eb86b57f468c68d6ec0c651e8b3feda1518 (patch) | |
tree | 65ea508b6730a9bf114b2210b18e4dba5b926a1b /html-test | |
parent | 9add5b561406cde1245f150deb3d2625e701399c (diff) |
Refactor handling of parens in types (#874)
* Fix type parenthesization in Hoogle backend
Ported the logic in the HTML and LaTeX backends for adding in parens
into something top-level in 'GhcUtil'. Calling that from the Hoogle
backend fixes #873.
* Remove parenthesizing logic from LaTeX and XHTML backends
Now, the only times that parenthesis in types are added in any backend
is through the explicit 'HsParTy' constructor. Precedence is also
represented as its own datatype.
* List out cases explicitly vs. catch-all
* Fix printing of parens for QuantifiedConstraints
The priority of printing 'forall' types was just one too high.
Fixes #877.
* Accept HTML output for quantified contexts test
Diffstat (limited to 'html-test')
-rw-r--r-- | html-test/ref/QuantifiedConstraints.html | 100 | ||||
-rw-r--r-- | html-test/src/QuantifiedConstraints.hs | 11 |
2 files changed, 111 insertions, 0 deletions
diff --git a/html-test/ref/QuantifiedConstraints.html b/html-test/ref/QuantifiedConstraints.html new file mode 100644 index 00000000..fa2c18ec --- /dev/null +++ b/html-test/ref/QuantifiedConstraints.html @@ -0,0 +1,100 @@ +<html xmlns="http://www.w3.org/1999/xhtml" +><head + ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" + /><title + >QuantifiedConstraints</title + ><link href="#" rel="stylesheet" type="text/css" title="Ocean" + /><link rel="stylesheet" type="text/css" href="#" + /><script src="haddock-bundle.min.js" async="async" 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 + ></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" + >QuantifiedConstraints</p + ></div + ><div id="interface" + ><h1 + >Documentation</h1 + ><div class="top" + ><p class="src" + ><span class="keyword" + >class</span + > <a id="t:Foo" class="def" + >Foo</a + > a <span class="keyword" + >where</span + > <a href="#" class="selflink" + >#</a + ></p + ><div class="subs methods" + ><p class="caption" + >Methods</p + ><p class="src" + ><a id="v:fooed" class="def" + >fooed</a + > :: a <a href="#" class="selflink" + >#</a + ></p + ></div + ></div + ><div class="top" + ><p class="src" + ><a id="v:needsParensAroundContext" class="def" + >needsParensAroundContext</a + > :: (<span class="keyword" + >forall</span + > x. <a href="#" title="QuantifiedConstraints" + >Foo</a + > (f x)) => f <a href="#" title="Data.Int" + >Int</a + > <a href="#" class="selflink" + >#</a + ></p + ></div + ><div class="top" + ><p class="src" + ><a id="v:needsNoParensAroundContext" class="def" + >needsNoParensAroundContext</a + > :: <a href="#" title="QuantifiedConstraints" + >Foo</a + > (f <a href="#" title="Data.Int" + >Int</a + >) => f <a href="#" title="Data.Int" + >Int</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/src/QuantifiedConstraints.hs b/html-test/src/QuantifiedConstraints.hs new file mode 100644 index 00000000..82dd81e5 --- /dev/null +++ b/html-test/src/QuantifiedConstraints.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE QuantifiedConstraints #-} +module QuantifiedConstraints where + +class Foo a where + fooed :: a + +needsParensAroundContext :: (forall x. Foo (f x)) => f Int +needsParensAroundContext = fooed + +needsNoParensAroundContext :: Foo (f Int) => f Int +needsNoParensAroundContext = fooed |