Value stored in a key-value map.
- ofString: String → Lean.DataValue
- ofBool: Bool → Lean.DataValue
- ofName: Lean.Name → Lean.DataValue
- ofNat: Nat → Lean.DataValue
- ofInt: Int → Lean.DataValue
- ofSyntax: Lean.Syntax → Lean.DataValue
Instances For
Equations
- Lean.instInhabitedDataValue = { default := Lean.DataValue.ofString default }
@[export lean_data_value_beq]
Instances For
@[export lean_mk_bool_data_value]
Instances For
@[export lean_data_value_bool]
Equations
- (Lean.DataValue.ofBool b).getBoolEx = b
- x.getBoolEx = false
Instances For
Equations
- (Lean.DataValue.ofString a).sameCtor (Lean.DataValue.ofString b) = true
- (Lean.DataValue.ofBool a).sameCtor (Lean.DataValue.ofBool b) = true
- (Lean.DataValue.ofName a).sameCtor (Lean.DataValue.ofName b) = true
- (Lean.DataValue.ofNat a).sameCtor (Lean.DataValue.ofNat b) = true
- (Lean.DataValue.ofInt a).sameCtor (Lean.DataValue.ofInt b) = true
- (Lean.DataValue.ofSyntax a).sameCtor (Lean.DataValue.ofSyntax b) = true
- x✝.sameCtor x = false
Instances For
@[export lean_data_value_to_string]
Equations
- (Lean.DataValue.ofString a).str = a
- (Lean.DataValue.ofBool a).str = toString a
- (Lean.DataValue.ofName a).str = toString a
- (Lean.DataValue.ofNat a).str = toString a
- (Lean.DataValue.ofInt a).str = toString a
- (Lean.DataValue.ofSyntax a).str = toString a
Instances For
Equations
- Lean.instToStringDataValue = { toString := Lean.DataValue.str }
Equations
- Lean.instCoeBoolDataValue = { coe := Lean.DataValue.ofBool }
Equations
- Lean.instCoeNatDataValue = { coe := Lean.DataValue.ofNat }
A key-value map. We use it to represent user-selected options and Expr.mdata
.
Remark: we do not use RBMap
here because we need to manipulate KVMap
objects in
C++ and RBMap
is implemented in Lean. So, we use just a List
until we can
generate C++ code from Lean code.
- entries : List (Lean.Name × Lean.DataValue)
Instances For
Equations
- Lean.instInhabitedKVMap = { default := { entries := default } }
Equations
- Lean.KVMap.instToString = { toString := fun (m : Lean.KVMap) => toString m.entries }
Equations
- { entries := m }.isEmpty = m.isEmpty
Instances For
Instances For
Equations
- m.findD k d₀ = (m.find k).getD d₀
Instances For
Equations
- Lean.KVMap.insertCore [] x✝ x = [(x✝, x)]
- Lean.KVMap.insertCore ((k, v) :: m) x✝ x = if (k == x✝) = true then (k, x) :: m else (k, v) :: Lean.KVMap.insertCore m x✝ x
Instances For
Erase an entry from the map
Equations
- { entries := m }.erase x = { entries := List.filter (fun (a : Lean.Name × Lean.DataValue) => decide (a.fst ≠ x)) m }
Instances For
Instances For
Equations
- m.getNat k defVal = match m.find k with | some (Lean.DataValue.ofNat v) => v | x => defVal
Instances For
Equations
- m.getBool k defVal = match m.find k with | some (Lean.DataValue.ofBool v) => v | x => defVal
Instances For
def
Lean.KVMap.getName
(m : Lean.KVMap)
(k : Lean.Name)
(defVal : Lean.Name := Lean.Name.anonymous)
:
Equations
- m.getName k defVal = match m.find k with | some (Lean.DataValue.ofName v) => v | x => defVal
Instances For
def
Lean.KVMap.getSyntax
(m : Lean.KVMap)
(k : Lean.Name)
(defVal : Lean.Syntax := Lean.Syntax.missing)
:
Instances For
Equations
- m.setString k v = m.insert k (Lean.DataValue.ofString v)
Instances For
Equations
- m.setInt k v = m.insert k (Lean.DataValue.ofInt v)
Instances For
Equations
- m.setName k v = m.insert k (Lean.DataValue.ofName v)
Instances For
Instances For
Update a String
entry based on its current value.
Equations
- m.updateString k f = m.insert k (Lean.DataValue.ofString (f (m.getString k)))
Instances For
Update a Nat
entry based on its current value.
Instances For
Update an Int
entry based on its current value.
Instances For
Update a Bool
entry based on its current value.
Instances For
Update a Name
entry based on its current value.
Equations
- m.updateName k f = m.insert k (Lean.DataValue.ofName (f (m.getName k)))
Instances For
Update a Syntax
entry based on its current value.
Equations
- m.updateSyntax k f = m.insert k (Lean.DataValue.ofSyntax (f (m.getSyntax k)))
Instances For
@[inline]
def
Lean.KVMap.forIn
{δ : Type w}
{m : Type w → Type w'}
[Monad m]
(kv : Lean.KVMap)
(init : δ)
(f : Lean.Name × Lean.DataValue → δ → m (ForInStep δ))
:
m δ
Instances For
def
Lean.KVMap.mergeBy
(mergeFn : Lean.Name → Lean.DataValue → Lean.DataValue → Lean.DataValue)
(l r : Lean.KVMap)
:
Instances For
Instances For
- toDataValue : α → Lean.DataValue
- ofDataValue? : Lean.DataValue → Option α
Instances
@[inline]
Instances For
@[inline]
Instances For
@[inline]
def
Lean.KVMap.update
{α : Type}
[Lean.KVMap.Value α]
(m : Lean.KVMap)
(k : Lean.Name)
(f : Option α → Option α)
:
Instances For
Equations
- Lean.KVMap.instValueBool = { toDataValue := Lean.DataValue.ofBool, ofDataValue? := fun (x : Lean.DataValue) => match x with | Lean.DataValue.ofBool b => some b | x => none }
Equations
- Lean.KVMap.instValueNat = { toDataValue := Lean.DataValue.ofNat, ofDataValue? := fun (x : Lean.DataValue) => match x with | Lean.DataValue.ofNat n => some n | x => none }
Equations
- Lean.KVMap.instValueInt = { toDataValue := Lean.DataValue.ofInt, ofDataValue? := fun (x : Lean.DataValue) => match x with | Lean.DataValue.ofInt i => some i | x => none }
Equations
- Lean.KVMap.instValueName = { toDataValue := Lean.DataValue.ofName, ofDataValue? := fun (x : Lean.DataValue) => match x with | Lean.DataValue.ofName n => some n | x => none }
Equations
- One or more equations did not get rendered due to their size.