pretty printing improvements
This commit is contained in:
parent
f4a45b6c52
commit
b6fd1e921e
3 changed files with 23 additions and 10 deletions
|
@ -114,4 +114,4 @@ prettyDef name (MkDef qty type _ _) = withPrec Outer $ do
|
||||||
name <- prettyFree name
|
name <- prettyFree name
|
||||||
colon <- colonD
|
colon <- colonD
|
||||||
type <- prettyTerm [<] [<] type
|
type <- prettyTerm [<] [<] type
|
||||||
pure $ sep [hsep [hcat [qty, dot, name], colon], type]
|
hangDSingle (hsep [hcat [qty, dot, name], colon]) type
|
||||||
|
|
|
@ -191,6 +191,14 @@ parameters {opts : LayoutOpts} {auto _ : Foldable t}
|
||||||
separateTight : Doc opts -> t (Doc opts) -> Doc opts
|
separateTight : Doc opts -> t (Doc opts) -> Doc opts
|
||||||
separateTight d = sep . exceptLast (<+> d) . toList
|
separateTight d = sep . exceptLast (<+> d) . toList
|
||||||
|
|
||||||
|
export
|
||||||
|
hseparateTight : Doc opts -> t (Doc opts) -> Doc opts
|
||||||
|
hseparateTight d = hsep . exceptLast (<+> d) . toList
|
||||||
|
|
||||||
|
export
|
||||||
|
vseparateTight : Doc opts -> t (Doc opts) -> Doc opts
|
||||||
|
vseparateTight d = vsep . exceptLast (<+> d) . toList
|
||||||
|
|
||||||
export
|
export
|
||||||
fillSeparateTight : Doc opts -> t (Doc opts) -> Doc opts
|
fillSeparateTight : Doc opts -> t (Doc opts) -> Doc opts
|
||||||
fillSeparateTight d = fillSep . exceptLast (<+> d) . toList
|
fillSeparateTight d = fillSep . exceptLast (<+> d) . toList
|
||||||
|
|
|
@ -251,12 +251,11 @@ parameters {opts : LayoutOpts} (dnames : BContext d) (tnames : BContext n)
|
||||||
body <- withPrec Outer $ assert_total
|
body <- withPrec Outer $ assert_total
|
||||||
prettyTerm (dnames . dbinds) (tnames . tbinds) body
|
prettyTerm (dnames . dbinds) (tnames . tbinds) body
|
||||||
header <- (pat <++>) <$> darrowD
|
header <- (pat <++>) <$> darrowD
|
||||||
pure $ hsep [header, body] <|> vsep [header, !(indentD body)]
|
pure $ ifMultiline (header <++> body) (vsep [header, !(indentD body)])
|
||||||
|
|
||||||
private
|
private
|
||||||
prettyCaseBody : List (CaseArm opts d n) -> Eff Pretty (Doc opts)
|
prettyCaseBody : List (CaseArm opts d n) -> Eff Pretty (List (Doc opts))
|
||||||
prettyCaseBody xs =
|
prettyCaseBody xs = traverse prettyCaseArm xs
|
||||||
braces . separateTight !semiD =<< traverse prettyCaseArm xs
|
|
||||||
|
|
||||||
private
|
private
|
||||||
prettyCompPat : {opts : _} -> DimConst -> BindName -> Eff Pretty (Doc opts)
|
prettyCompPat : {opts : _} -> DimConst -> BindName -> Eff Pretty (Doc opts)
|
||||||
|
@ -299,7 +298,7 @@ prettyCaseRet dnames tnames body = withPrec Outer $ case body of
|
||||||
S [< x] (Y tm) => do
|
S [< x] (Y tm) => do
|
||||||
header <- [|prettyTBind x <++> darrowD|]
|
header <- [|prettyTBind x <++> darrowD|]
|
||||||
body <- assert_total prettyTerm dnames (tnames :< x) tm
|
body <- assert_total prettyTerm dnames (tnames :< x) tm
|
||||||
pure $ hsep [header, body] <|> vsep [header, !(indentD body)]
|
hangDSingle header body
|
||||||
|
|
||||||
private
|
private
|
||||||
prettyCase_ : {opts : _} ->
|
prettyCase_ : {opts : _} ->
|
||||||
|
@ -309,8 +308,14 @@ prettyCase_ : {opts : _} ->
|
||||||
prettyCase_ dnames tnames intro head ret body = do
|
prettyCase_ dnames tnames intro head ret body = do
|
||||||
head <- assert_total prettyElim dnames tnames head
|
head <- assert_total prettyElim dnames tnames head
|
||||||
ret <- prettyCaseRet dnames tnames ret
|
ret <- prettyCaseRet dnames tnames ret
|
||||||
body <- prettyCaseBody dnames tnames body
|
bodys <- prettyCaseBody dnames tnames body
|
||||||
parensIfM Outer $ sep [intro <++> head, !returnD <++> ret, !ofD <++> body]
|
return <- returnD; of_ <- ofD
|
||||||
|
lb <- hl Delim "{"; rb <- hl Delim "}"; semi <- semiD
|
||||||
|
ind <- askAt INDENT
|
||||||
|
parensIfM Outer $ ifMultiline
|
||||||
|
(hsep [intro, head, return, ret, of_, lb, hseparateTight semi bodys, rb])
|
||||||
|
(vsep [intro <++> head, return <++> ret, of_ <++> lb,
|
||||||
|
indent ind $ vseparateTight semi bodys, rb])
|
||||||
|
|
||||||
private
|
private
|
||||||
prettyCase : {opts : _} ->
|
prettyCase : {opts : _} ->
|
||||||
|
|
Loading…
Reference in a new issue