add runPrettyWith, etc

This commit is contained in:
rhiannon morris 2023-03-25 20:48:26 +01:00
parent 60079d9eb9
commit 100063ab91
2 changed files with 17 additions and 10 deletions

View file

@ -175,14 +175,26 @@ pretty0M : (PrettyHL a, HasEnv m) => a -> m (Doc HL)
pretty0M = local {prec := Outer} . prettyM
export %inline
runPretty : (unicode : Bool) -> Reader PrettyEnv a -> a
runPretty unicode act =
let env = MakePrettyEnv {dnames = [<], tnames = [<], unicode, prec = Outer} in
runPrettyWith : (unicode : Bool) -> (dnames, tnames : SnocList BaseName) ->
Reader PrettyEnv a -> a
runPrettyWith unicode dnames tnames act =
let env = MakePrettyEnv {dnames, tnames, unicode, prec = Outer} in
runReader env act
export %inline
runPretty : (unicode : Bool) -> Reader PrettyEnv a -> a
runPretty unicode = runPrettyWith unicode [<] [<]
export %inline
pretty0With : PrettyHL a => (unicode : Bool) ->
(dnames, tnames : SnocList BaseName) ->
a -> Doc HL
pretty0With {unicode, dnames, tnames} =
runPrettyWith {unicode, dnames, tnames} . prettyM
export %inline
pretty0 : PrettyHL a => (unicode : Bool) -> a -> Doc HL
pretty0 unicode = runPretty unicode . prettyM
pretty0 unicode = pretty0With unicode [<] [<]
export

View file

@ -271,9 +271,4 @@ prettyTerm : IsQty q => PrettyHL q => (unicode : Bool) ->
(dnames : NContext d) -> (tnames : NContext n) ->
Term q d n -> Doc HL
prettyTerm unicode dnames tnames term =
let env = MakePrettyEnv {
dnames = toSnocList' dnames,
tnames = toSnocList' tnames,
unicode, prec = Outer
} in
runReader env $ prettyM term
pretty0With unicode (toSnocList' dnames) (toSnocList' tnames) term