TOML Encoders #
This module contains definitions to assist in encoding Lean types into TOML data values.
@[instance_reducible]
Equations
- Lake.instToTomlValue = { toToml := id }
@[instance_reducible]
Equations
@[instance_reducible]
Equations
- Lake.instToTomlFilePath = { toToml := fun (x : System.FilePath) => Lake.toToml (Lake.mkRelPathString x) }
@[instance_reducible]
Equations
- Lake.instToTomlName = { toToml := fun (x : Lean.Name) => Lake.toToml x.toString }
@[instance_reducible]
Equations
@[instance_reducible]
Equations
- Lake.instToTomlNat = { toToml := fun (n : Nat) => Lake.Toml.Value.integer Lean.Syntax.missing (Int.ofNat n) }
@[instance_reducible]
Equations
@[instance_reducible]
Equations
@[instance_reducible]
Equations
- Lake.instToTomlArray = { toToml := fun (x : Array α) => Lake.Toml.Value.array Lean.Syntax.missing (Array.map Lake.toToml x) }
@[instance_reducible]
Equations
- Lake.instToTomlArrayValue = { toToml := fun (x : Array Lake.Toml.Value) => Lake.Toml.Value.array Lean.Syntax.missing x }
@[instance_reducible]
Equations
@[instance_reducible, instance 10000]
Equations
- Lake.instToToml?OfToToml = { toToml? := fun (v : α) => some (Lake.toToml v) }
Equations
- Lake.Toml.encodeArray? as = Array.foldl (fun (vs? : Option (Array Lake.Toml.Value)) (a : α) => do let vs ← vs? let v ← Lake.toToml? a pure (vs.push v)) (some #[]) as
Instances For
@[instance_reducible]
Equations
- Lake.instToToml?Array = { toToml? := fun (as : Array α) => Lake.toToml <$> Lake.Toml.encodeArray? as }
@[instance_reducible]
Equations
- Lake.instToToml?Option = { toToml? := fun (x : Option α) => x.bind Lake.toToml? }
@[instance_reducible]
Equations
- Lake.instToToml?OptionOfToToml = { toToml? := fun (x : Option α) => Option.map Lake.toToml x }
@[instance_reducible, instance 100]
Equations
- Lake.Toml.instSmartInsertOfToToml? = { smartInsert := fun (k : Lean.Name) (v : α) (t : Lake.Toml.Table) => Lake.Toml.RBDict.insertSome k (Lake.toToml? v) t }
@[instance_reducible]
Equations
- Lake.Toml.instSmartInsertTable = { smartInsert := fun (k : Lean.Name) (v t : Lake.Toml.Table) => Lake.Toml.RBDict.insertUnless (Lake.Toml.RBDict.isEmpty v) k (Lake.toToml v) t }
@[instance_reducible]
instance Lake.Toml.instSmartInsertArrayOfToToml {α : Type u_1} [ToToml (Array α)] :
SmartInsert (Array α)
Equations
- Lake.Toml.instSmartInsertArrayOfToToml = { smartInsert := fun (k : Lean.Name) (v : Array α) (t : Lake.Toml.Table) => Lake.Toml.RBDict.insertUnless v.isEmpty k (Lake.toToml v) t }
@[instance_reducible]
Equations
- Lake.Toml.instSmartInsertString = { smartInsert := fun (k : Lean.Name) (v : String) (t : Lake.Toml.Table) => Lake.Toml.RBDict.insertUnless v.isEmpty k (Lake.toToml v) t }
@[inline]
Inserts the encoded value into the table.
Equations
- Lake.Toml.Table.insert k v t = Lake.Toml.RBDict.insert k (Lake.toToml v) t
Instances For
@[macro_inline]
def Lake.Toml.Table.insertSome {α : Type u_1} [enc : ToToml α] (k : Lean.Name) (v? : Option α) (t : Table) :
If the value is not none, inserts the encoded value into the table.
Equations
- Lake.Toml.Table.insertSome k v? t = Lake.Toml.RBDict.insertSome k (Option.map Lake.toToml v?) t
Instances For
@[instance_reducible]
instance Lake.Toml.Table.instSmartInsertOptionOfToToml {α : Type u_1} [ToToml α] :
SmartInsert (Option α)
Equations
- Lake.Toml.Table.instSmartInsertOptionOfToToml = { smartInsert := Lake.Toml.Table.insertSome }
@[inline]
def Lake.Toml.Table.smartInsert {α : Type u_1} [SmartInsert α] (k : Lean.Name) (v : α) (t : Table) :
Insert a value into the table unless it represents a nullish value.
Equations
Instances For
@[macro_inline]
def Lake.Toml.Table.insertIf {α : Type u_1} [enc : ToToml α] (p : Bool) (k : Lean.Name) (v : α) (t : Table) :
Insert a value into the table if p is true.
Equations
- Lake.Toml.Table.insertIf p k v t = Lake.Toml.RBDict.insertIf p k (Lake.toToml v) t
Instances For
@[macro_inline]
def Lake.Toml.Table.insertUnless {α : Type u_1} [enc : ToToml α] (p : Bool) (k : Lean.Name) (v : α) (t : Table) :
Insert a value into the table if p is false.
Equations
- Lake.Toml.Table.insertUnless p k v t = Lake.Toml.RBDict.insertUnless p k (Lake.toToml v) t
Instances For
@[inline]
def Lake.Toml.Table.insertD {α : Type u_1} [enc : ToToml α] [BEq α] (k : Lean.Name) (v default : α) (t : Table) :
Inserts the value into the table if it is not equal to default.
Equations
- Lake.Toml.Table.insertD k v default t = Lake.Toml.Table.insertUnless (v == default) k (Lake.toToml v) t