Skip to content

Commit

Permalink
Place parens appropriately when pretty printing types.
Browse files Browse the repository at this point in the history
Fixes #835.
  • Loading branch information
Brian Huffman committed Jul 28, 2020
1 parent 5100132 commit 9a5b04a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Cryptol/TypeCheck/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,16 @@ instance PP (WithNames Newtype) where




-- | The precedence levels used by this pretty-printing instance
-- correspond with parser non-terminals as follows:
--
-- * 0-1: @type@
--
-- * 2: @infix_type@
--
-- * 3: @app_type@
--
-- * 4: @atype@
instance PP (WithNames Type) where
ppPrec prec ty0@(WithNames ty nmMap) =
case ty of
Expand Down Expand Up @@ -867,7 +876,7 @@ instance PP (WithNames Type) where

(TCTuple _, fs) -> parens $ fsep $ punctuate comma $ map (go 0) fs

(_, _) -> pp tc <+> fsep (map (go 5) ts)
(_, _) -> optParens (prec > 3) $ pp tc <+> fsep (map (go 4) ts)

TCon (PC pc) ts ->
case (pc,ts) of
Expand Down

0 comments on commit 9a5b04a

Please sign in to comment.