- allOrNone: Std.Format.FlattenBehavior
- fill: Std.Format.FlattenBehavior
Equations
Equations
- Std.Format.instBEqFlattenBehavior = { beq := [anonymous] }
- nil: Std.Format
- line: Std.Format
- text: String → Std.Format
- nest: Int → Std.Format → Std.Format
- append: Std.Format → Std.Format → Std.Format
- group: Std.Format → optParam Std.Format.FlattenBehavior Std.Format.FlattenBehavior.allOrNone → Std.Format
- tag: Nat → Std.Format → Std.Format
Equations
- Std.instInhabitedFormat = { default := Std.Format.nil }
Equations
- Std.Format.isEmpty Std.Format.nil = true
- Std.Format.isEmpty Std.Format.line = false
- Std.Format.isEmpty (Std.Format.text msg) = (msg == "")
- Std.Format.isEmpty (Std.Format.nest indent f) = Std.Format.isEmpty f
- Std.Format.isEmpty (Std.Format.append f₁ f₂) = (Std.Format.isEmpty f₁ && Std.Format.isEmpty f₂)
- Std.Format.isEmpty (Std.Format.group f behavior) = Std.Format.isEmpty f
- Std.Format.isEmpty (Std.Format.tag a f) = Std.Format.isEmpty f
Equations
Equations
- Std.Format.appendEx a b = Std.Format.append a b
Equations
Equations
- Std.Format.instAppendFormat = { append := Std.Format.append }
Equations
- Std.Format.instCoeStringFormat = { coe := Std.Format.text }
Equations
- Std.Format.join xs = List.foldl (fun a a_1 => a ++ a_1) (Std.Format.text "") xs
Equations
- Std.Format.isNil _fun_discr = match _fun_discr with | Std.Format.nil => true | x => false
Equations
- Std.Format.instInhabitedSpaceResult = { default := { foundLine := default, foundFlattenedHardLine := default, space := default } }
def
Std.Format.prettyM
{m : Type → Type}
(f : Std.Format)
(w : Nat)
(indent : optParam Nat 0)
[inst : Monad m]
[inst : Std.Format.MonadPrettyFormat m]
:
m Unit
Equations
- Std.Format.prettyM f w indent = Std.Format.be w [{ flatten := false, flb := Std.Format.FlattenBehavior.allOrNone, items := [{ f := f, indent := Int.ofNat indent, activeTags := 0 }] }]
@[inline]
Equations
- Std.Format.bracket l f r = Std.Format.group (Std.Format.nest (Int.ofNat (String.length l)) (Std.Format.text l ++ f ++ Std.Format.text r))
@[inline]
Equations
- Std.Format.paren f = Std.Format.bracket "(" f ")"
@[inline]
Equations
- Std.Format.sbracket f = Std.Format.bracket "[" f "]"
@[inline]
Equations
- Std.Format.bracketFill l f r = Std.Format.fill (Std.Format.nest (Int.ofNat (String.length l)) (Std.Format.text l ++ f ++ Std.Format.text r))
Equations
Equations
Equations
- Std.Format.instMonadPrettyFormatStateMState = { pushOutput := fun s => modify fun x => match x with | { out := out, column := col } => { out := out ++ s, column := col + String.length s }, pushNewline := fun indent => modify fun x => match x with | { out := out, column := column } => { out := out ++ String.pushn "\n" (Char.ofNat 32) indent, column := indent }, currColumn := do let a ← get pure a.column, startTag := fun x => pure (), endTags := fun x => pure () }
Equations
- Std.Format.pretty f w = let act := Std.Format.prettyM f w 0; (act { out := "", column := 0 }).snd.out
Pretty-print a Format
object as a string with expected width w
.
- format : α → Std.Format
Equations
- Std.instToFormatFormat = { format := fun f => f }
Equations
- Std.instToFormatString = { format := fun s => Std.Format.text s }
Equations
- Std.Format.joinSep [] _fun_discr = Std.Format.nil
- Std.Format.joinSep [a] _fun_discr = Std.format a
- Std.Format.joinSep (a :: as) _fun_discr = Std.format a ++ _fun_discr ++ Std.Format.joinSep as _fun_discr
def
Std.Format.prefixJoin
{α : Type u}
[inst : Std.ToFormat α]
(pre : Std.Format)
:
List α → Std.Format
Equations
- Std.Format.prefixJoin pre [] = Std.Format.nil
- Std.Format.prefixJoin pre (a :: as) = pre ++ Std.format a ++ Std.Format.prefixJoin pre as
Equations
- Std.Format.joinSuffix [] _fun_discr = Std.Format.nil
- Std.Format.joinSuffix (a :: as) _fun_discr = Std.format a ++ _fun_discr ++ Std.Format.joinSuffix as _fun_discr