Skip to content

Commit

Permalink
Special case in pretty-printer for bind
Browse files Browse the repository at this point in the history
However, the way we stagger boxes still isn't quite right.
  • Loading branch information
edsko committed Jun 14, 2016
1 parent 06602e7 commit e35d2ca
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/CBN/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ instance ToDoc Term where
toDoc' _ (TPtr n) = toDoc n
toDoc' fc (TPrim pes ) = toDoc' fc pes
toDoc' fc (TCon ces) = toDoc' fc ces

-- special case for @bind e1 (\x -> e2)@
toDoc' fc (TApp (TApp (TPtr (Ptr Nothing (Just "bind"))) e1) (TLam x e2)) =
parensIfChoice (needsParens fc Ap) $ [
stack [
doc "bind" <+> toDoc' (R Ap) e1 <+> doc "(\\" <> toDoc x <+> doc "->"
, toDoc' (R Lam) e2 <> doc ")"
]
]

-- standard rendering
toDoc' fc (TApp e1 e2) = parensIf (needsParens fc Ap) $
toDoc' (L Ap) e1 <+> toDoc' (R Ap) e2
toDoc' fc (TSeq e1 e2) = parensIf (needsParens fc Ap) $
Expand Down

0 comments on commit e35d2ca

Please sign in to comment.