[GHC] #8403: Pretty-printing of long types
GHC
ghc-devs at haskell.org
Mon Apr 20 07:38:44 UTC 2015
#8403: Pretty-printing of long types
-------------------------------------+-------------------------------------
Reporter: monoidal | Owner:
Type: bug | Status: new
Priority: lowest | Milestone:
Component: Compiler | Version: 7.6.3
Resolution: | Keywords: newcomer
Operating System: Unknown/Multiple | Architecture:
Type of failure: Other | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: #9428 | Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by phadej):
With the test program:
{{{
import Text.PrettyPrint
-- mocking how compiler/types/TypeRep.hs would print the type
pairUntil :: Char -> Doc
pairUntil c = pprArrowChain (varDocs ++ [resultPair])
where varDocs = map char ['a'..c]
resultPair = parens (sep (punctuate comma varDocs))
arrow :: Doc
arrow = text "->"
pprArrowChain :: [Doc] -> Doc
-- pprArrowChain [a,b,c] generates a -> b -> c
pprArrowChain [] = empty
pprArrowChain (arg:args) = sep [arg, sep (map (arrow <+>) args)]
}}}
{{{
λ> Test.pairUntil 'd'
a -> b -> c -> d -> (a, b, c, d)
λ> Test.pairUntil 'k'
a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> (a, b, c, d, e, f, g, h, i, j, k)
}}}
I have no good ideas how to define "more packed", yet so output is still
understandable. E.g. will this "less area" method work for all types:
{{{
a -> b -> c -> d -> e -> f -> g -> h -> i -> j
-> k -> l -> m -> n -> o -> p -> q -> r -> s
-> t -> u -> v -> w -> x
-> (a, b, c, d, e, f, g, h, i, j, k, l,
m, n, o, p, q, r, s, t, u, v, w, x)
}}}
My gut feelings that the layout algorithm won't be linear anymore, don't
know if that is the problem though.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8403#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list