aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2018-08-21 10:05:01 -0700
committerAlec Theriault <alec.theriault@gmail.com>2018-08-21 22:06:40 -0700
commitb417271702b81d7893308c3ce6df4b5babeaa55c (patch)
tree6b416e23e22e08f0a4d5eb7a3694ec6a9db2f223
parent9ef12f3c2f0ef2948e6f4bd38fdfa002c416ab09 (diff)
Better rendering of unboxed sums/tuples
* adds space after/before the '#' marks * properly reify 'HsSumTy' in 'synifyType'
-rw-r--r--haddock-api/src/Haddock/Backends/LaTeX.hs4
-rw-r--r--haddock-api/src/Haddock/Backends/Xhtml/Utils.hs2
-rw-r--r--haddock-api/src/Haddock/Convert.hs1
-rw-r--r--html-test/src/UnboxedStuff.hs18
-rw-r--r--latex-test/src/UnboxedStuff/UnboxedStuff.hs18
5 files changed, 40 insertions, 3 deletions
diff --git a/haddock-api/src/Haddock/Backends/LaTeX.hs b/haddock-api/src/Haddock/Backends/LaTeX.hs
index 4e0e6eba..0c7747bd 100644
--- a/haddock-api/src/Haddock/Backends/LaTeX.hs
+++ b/haddock-api/src/Haddock/Backends/LaTeX.hs
@@ -974,7 +974,7 @@ tupleParens _ = parenList
sumParens :: [LaTeX] -> LaTeX
-sumParens = ubxparens . hsep . punctuate (text " | ")
+sumParens = ubxparens . hsep . punctuate (text " |")
-------------------------------------------------------------------------------
@@ -1335,7 +1335,7 @@ ubxParenList = ubxparens . hsep . punctuate comma
ubxparens :: LaTeX -> LaTeX
-ubxparens h = text "(#" <> h <> text "#)"
+ubxparens h = text "(#" <+> h <+> text "#)"
nl :: LaTeX
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs b/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs
index 7fbaec6d..62781fd0 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs
@@ -183,7 +183,7 @@ ubxSumList = ubxparens . hsep . punctuate (toHtml " | ")
ubxparens :: Html -> Html
-ubxparens h = toHtml "(#" +++ h +++ toHtml "#)"
+ubxparens h = toHtml "(#" <+> h <+> toHtml "#)"
dcolon, arrow, darrow, forallSymbol :: Bool -> Html
diff --git a/haddock-api/src/Haddock/Convert.hs b/haddock-api/src/Haddock/Convert.hs
index 044e1e11..71482f22 100644
--- a/haddock-api/src/Haddock/Convert.hs
+++ b/haddock-api/src/Haddock/Convert.hs
@@ -457,6 +457,7 @@ synifyType _ (TyConApp tc tys)
ConstraintTuple -> HsConstraintTuple
UnboxedTuple -> HsUnboxedTuple)
(map (synifyType WithinType) vis_tys)
+ | isUnboxedSumTyCon tc = noLoc $ HsSumTy noExt (map (synifyType WithinType) vis_tys)
-- ditto for lists
| getName tc == listTyConName, [ty] <- tys =
noLoc $ HsListTy noExt (synifyType WithinType ty)
diff --git a/html-test/src/UnboxedStuff.hs b/html-test/src/UnboxedStuff.hs
new file mode 100644
index 00000000..bd1b1302
--- /dev/null
+++ b/html-test/src/UnboxedStuff.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE UnboxedSums, UnboxedTuples #-}
+module UnboxedStuff where
+
+data X
+data Y
+data Z
+
+-- * Unboxed type constructors
+
+unboxedUnit :: (# #) -> (# #)
+unboxedUnit = undefined
+
+unboxedTuple :: (# X, Y #) -> (# X, Y, Z #)
+unboxedTuple = undefined
+
+unboxedSum :: (# X | Y #) -> (# X | Y | Z #)
+unboxedSum = undefined
+
diff --git a/latex-test/src/UnboxedStuff/UnboxedStuff.hs b/latex-test/src/UnboxedStuff/UnboxedStuff.hs
new file mode 100644
index 00000000..bd1b1302
--- /dev/null
+++ b/latex-test/src/UnboxedStuff/UnboxedStuff.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE UnboxedSums, UnboxedTuples #-}
+module UnboxedStuff where
+
+data X
+data Y
+data Z
+
+-- * Unboxed type constructors
+
+unboxedUnit :: (# #) -> (# #)
+unboxedUnit = undefined
+
+unboxedTuple :: (# X, Y #) -> (# X, Y, Z #)
+unboxedTuple = undefined
+
+unboxedSum :: (# X | Y #) -> (# X | Y | Z #)
+unboxedSum = undefined
+