move BannerOpts to PrettyOpts
This commit is contained in:
parent
9088ec02a0
commit
2446655b08
2 changed files with 30 additions and 25 deletions
|
@ -14,6 +14,16 @@ import public Control.Monad.Reader
|
|||
%default total
|
||||
|
||||
|
||||
public export
|
||||
record PrettyOpts where
|
||||
constructor MakePrettyOpts
|
||||
unicode, color : Bool
|
||||
|
||||
public export
|
||||
defPrettyOpts : PrettyOpts
|
||||
defPrettyOpts = MakePrettyOpts {unicode = True, color = True}
|
||||
|
||||
|
||||
public export
|
||||
data HL
|
||||
= Delim
|
||||
|
@ -160,8 +170,8 @@ pretty0M : (PrettyHL a, HasEnv m) => a -> m (Doc HL)
|
|||
pretty0M = local {prec := Outer} . prettyM
|
||||
|
||||
export %inline
|
||||
pretty0 : PrettyHL a => {default True unicode : Bool} -> a -> Doc HL
|
||||
pretty0 x {unicode} =
|
||||
pretty0 : PrettyHL a => (unicode : Bool) -> a -> Doc HL
|
||||
pretty0 unicode x =
|
||||
let env = MakePrettyEnv {dnames = [], tnames = [], unicode, prec = Outer} in
|
||||
runReader env $ prettyM x
|
||||
|
||||
|
@ -180,10 +190,10 @@ export PrettyHL Name where prettyM = pure . pretty . toDots
|
|||
|
||||
|
||||
export %inline
|
||||
prettyStr : PrettyHL a => {default True unicode : Bool} -> a -> String
|
||||
prettyStr {unicode} =
|
||||
prettyStr : PrettyHL a => (unicode : Bool) -> a -> String
|
||||
prettyStr unicode =
|
||||
let layout = layoutSmart (MkLayoutOptions (AvailablePerLine 80 0.8)) in
|
||||
renderString . layout . pretty0 {unicode}
|
||||
renderString . layout . pretty0 unicode
|
||||
|
||||
|
||||
export
|
||||
|
@ -199,10 +209,14 @@ termHL Free = color BrightWhite
|
|||
termHL Syntax = color BrightCyan
|
||||
|
||||
export %inline
|
||||
prettyTerm : {default True color, unicode : Bool} -> PrettyHL a => a -> IO Unit
|
||||
prettyTerm x {color, unicode} =
|
||||
let reann = if color then map termHL else unAnnotate in
|
||||
Terminal.putDoc $ reann $ pretty0 x {unicode}
|
||||
prettyTerm : PrettyOpts -> PrettyHL a => a -> IO Unit
|
||||
prettyTerm opts x =
|
||||
let reann = if opts.color then map termHL else unAnnotate in
|
||||
Terminal.putDoc $ reann $ pretty0 opts.unicode x
|
||||
|
||||
export %inline
|
||||
prettyTermDef : PrettyHL a => a -> IO Unit
|
||||
prettyTermDef = prettyTerm defPrettyOpts
|
||||
|
||||
|
||||
infixr 6 <//>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue