diff options
author | Alec Theriault <alec.theriault@gmail.com> | 2018-08-04 11:51:30 -0400 |
---|---|---|
committer | Alec Theriault <alec.theriault@gmail.com> | 2018-10-16 16:28:55 -0700 |
commit | 9f2d1b933897a6330e5c8f9fa904e56ab40050ef (patch) | |
tree | 171681a8bd3ea2437f029fdf88fa8336efcd712f /html-test | |
parent | 41d9846754cdccb82e667ece2f44725ed9cab4e7 (diff) |
Latex type families (#734)
* Support for type families in LaTeX
The code is ported over from the XHTML backend.
* Refactor XHTML and LaTeX family handling
This is mostly a consolidation effort: stripping extra exports,
inlining some short definitions, and trying to make the backends
match.
The LaTeX backend now has preliminary support for data families,
although the only the data instance head is printed (not the actual constructors).
Both backends also now use "newtype" for newtype data family
instances.
* Add some tests
Diffstat (limited to 'html-test')
-rw-r--r-- | html-test/ref/TypeFamilies3.html | 356 | ||||
-rw-r--r-- | html-test/src/TypeFamilies3.hs | 21 |
2 files changed, 377 insertions, 0 deletions
diff --git a/html-test/ref/TypeFamilies3.html b/html-test/ref/TypeFamilies3.html new file mode 100644 index 00000000..2dadf435 --- /dev/null +++ b/html-test/ref/TypeFamilies3.html @@ -0,0 +1,356 @@ +<html xmlns="http://www.w3.org/1999/xhtml" +><head + ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" + /><title + >TypeFamilies3</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" + >TypeFamilies3</p + ></div + ><div id="synopsis" + ><details id="syn" + ><summary + >Synopsis</summary + ><ul class="details-toggle" data-details-id="syn" + ><li class="src short" + ><span class="keyword" + >type family</span + > <a href="#" + >Foo</a + > a <span class="keyword" + >where ...</span + ></li + ><li class="src short" + ><span class="keyword" + >type family</span + > <a href="#" + >Bar</a + > a</li + ><li class="src short" + ><span class="keyword" + >data family</span + > <a href="#" + >Baz</a + > a</li + ></ul + ></details + ></div + ><div id="interface" + ><h1 + >Documentation</h1 + ><div class="top" + ><p class="src" + ><span class="keyword" + >type family</span + > <a id="t:Foo" class="def" + >Foo</a + > a <span class="keyword" + >where ...</span + > <a href="#" class="selflink" + >#</a + ></p + ><div class="doc" + ><p + >A closed type family</p + ></div + ><div class="subs equations" + ><p class="caption" + >Equations</p + ><table + ><tr + ><td class="src" + ><a href="#" title="TypeFamilies3" + >Foo</a + > () = <a href="#" title="Data.Int" + >Int</a + ></td + ><td class="doc empty" + ></td + ></tr + ><tr + ><td class="src" + ><a href="#" title="TypeFamilies3" + >Foo</a + > _ = ()</td + ><td class="doc empty" + ></td + ></tr + ></table + ></div + ></div + ><div class="top" + ><p class="src" + ><span class="keyword" + >type family</span + > <a id="t:Bar" class="def" + >Bar</a + > a <a href="#" class="selflink" + >#</a + ></p + ><div class="doc" + ><p + >An open family</p + ></div + ><div class="subs instances" + ><details id="i:Bar" open="open" + ><summary + >Instances</summary + ><table + ><tr + ><td class="src clearfix" + ><span class="inst-left" + ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Bar:Bar:1" + ></span + > <span class="keyword" + >type</span + > <a href="#" title="TypeFamilies3" + >Bar</a + > <a href="#" title="Data.Int" + >Int</a + ></span + > <a href="#" class="selflink" + >#</a + ></td + ><td class="doc empty" + ></td + ></tr + ><tr + ><td colspan="2" + ><details id="i:if:Bar:Bar:1" + ><summary class="hide-when-js-enabled" + >Instance details</summary + ><p + >Defined in <a href="#" + >TypeFamilies3</a + ></p + > <div class="src" + ><span class="keyword" + >type</span + > <a href="#" title="TypeFamilies3" + >Bar</a + > <a href="#" title="Data.Int" + >Int</a + > = ()</div + ></details + ></td + ></tr + ><tr + ><td class="src clearfix" + ><span class="inst-left" + ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Bar:Bar:2" + ></span + > <span class="keyword" + >type</span + > <a href="#" title="TypeFamilies3" + >Bar</a + > ()</span + > <a href="#" class="selflink" + >#</a + ></td + ><td class="doc empty" + ></td + ></tr + ><tr + ><td colspan="2" + ><details id="i:if:Bar:Bar:2" + ><summary class="hide-when-js-enabled" + >Instance details</summary + ><p + >Defined in <a href="#" + >TypeFamilies3</a + ></p + > <div class="src" + ><span class="keyword" + >type</span + > <a href="#" title="TypeFamilies3" + >Bar</a + > () = <a href="#" title="Data.Int" + >Int</a + ></div + ></details + ></td + ></tr + ></table + ></details + ></div + ></div + ><div class="top" + ><p class="src" + ><span class="keyword" + >data family</span + > <a id="t:Baz" class="def" + >Baz</a + > a <a href="#" class="selflink" + >#</a + ></p + ><div class="doc" + ><p + >A data family</p + ></div + ><div class="subs instances" + ><details id="i:Baz" open="open" + ><summary + >Instances</summary + ><table + ><tr + ><td class="src clearfix" + ><span class="inst-left" + ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Baz:Baz:1" + ></span + > <span class="keyword" + >newtype</span + > <a href="#" title="TypeFamilies3" + >Baz</a + > <a href="#" title="Prelude" + >Double</a + ></span + > <a href="#" class="selflink" + >#</a + ></td + ><td class="doc empty" + ></td + ></tr + ><tr + ><td colspan="2" + ><details id="i:if:Baz:Baz:1" + ><summary class="hide-when-js-enabled" + >Instance details</summary + ><p + >Defined in <a href="#" + >TypeFamilies3</a + ></p + > <div class="src" + ><span class="keyword" + >newtype</span + > <a href="#" title="TypeFamilies3" + >Baz</a + > <a href="#" title="Prelude" + >Double</a + > = <a id="v:Baz3" class="def" + >Baz3</a + > <a href="#" title="Prelude" + >Float</a + ></div + ></details + ></td + ></tr + ><tr + ><td class="src clearfix" + ><span class="inst-left" + ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Baz:Baz:2" + ></span + > <span class="keyword" + >data</span + > <a href="#" title="TypeFamilies3" + >Baz</a + > <a href="#" title="Data.Int" + >Int</a + ></span + > <a href="#" class="selflink" + >#</a + ></td + ><td class="doc empty" + ></td + ></tr + ><tr + ><td colspan="2" + ><details id="i:if:Baz:Baz:2" + ><summary class="hide-when-js-enabled" + >Instance details</summary + ><p + >Defined in <a href="#" + >TypeFamilies3</a + ></p + > <div class="src" + ><span class="keyword" + >data</span + > <a href="#" title="TypeFamilies3" + >Baz</a + > <a href="#" title="Data.Int" + >Int</a + > = <a id="v:Baz2" class="def" + >Baz2</a + > <a href="#" title="Data.Bool" + >Bool</a + ></div + ></details + ></td + ></tr + ><tr + ><td class="src clearfix" + ><span class="inst-left" + ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Baz:Baz:3" + ></span + > <span class="keyword" + >data</span + > <a href="#" title="TypeFamilies3" + >Baz</a + > ()</span + > <a href="#" class="selflink" + >#</a + ></td + ><td class="doc empty" + ></td + ></tr + ><tr + ><td colspan="2" + ><details id="i:if:Baz:Baz:3" + ><summary class="hide-when-js-enabled" + >Instance details</summary + ><p + >Defined in <a href="#" + >TypeFamilies3</a + ></p + > <div class="src" + ><span class="keyword" + >data</span + > <a href="#" title="TypeFamilies3" + >Baz</a + > () = <a id="v:Baz1" class="def" + >Baz1</a + ></div + ></details + ></td + ></tr + ></table + ></details + ></div + ></div + ></div + ></div + ><div id="footer" + ></div + ></body + ></html +>
\ No newline at end of file diff --git a/html-test/src/TypeFamilies3.hs b/html-test/src/TypeFamilies3.hs new file mode 100644 index 00000000..bde05fb8 --- /dev/null +++ b/html-test/src/TypeFamilies3.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE TypeFamilies #-} + +module TypeFamilies3 where + +-- | A closed type family +type family Foo a where + Foo () = Int + Foo _ = () + +-- | An open family +type family Bar a + +type instance Bar Int = () +type instance Bar () = Int + +-- | A data family +data family Baz a + +data instance Baz () = Baz1 +data instance Baz Int = Baz2 Bool +newtype instance Baz Double = Baz3 Float |