TOML Decoders #
This module contains definitions to assist in decoding TOML data values into concrete user types.
Equations
Instances For
Equations
Instances For
Equations
Instances For
Run the decode action. If there were errors, throw. Otherwise, return the result.
Equations
- Lake.Toml.ensureDecode x es = match x es with | EStateM.Result.ok a es => if es.isEmpty = true then EStateM.Result.ok a es else EStateM.Result.error () es
Instances For
Run the decode action. If it fails, keep the errors but return default
.
Equations
- Lake.Toml.tryDecodeD default x es = match x es with | EStateM.Result.ok a es => EStateM.Result.ok a es | EStateM.Result.error a es => EStateM.Result.ok default es
Instances For
Run the decode action. If it fails, keep the errors but return none
.
Equations
- Lake.Toml.tryDecode? x es = match x es with | EStateM.Result.ok a es => EStateM.Result.ok (some a) es | EStateM.Result.error a es => EStateM.Result.ok none es
Instances For
Run the decode action. If it fails, keep the errors but return Inhabited.default
.
Equations
Instances For
If the value is not none
, run the decode action.
If it fails, add the errors to the state and return default
.
Equations
- Lake.Toml.optDecodeD default (some a) f = Lake.Toml.tryDecodeD default (f a)
- Lake.Toml.optDecodeD default none f = pure default
Instances For
If the value is not none
, run the decode action.
If it fails, add the errors to the state and return Inhabited.default
.
Equations
- Lake.Toml.optDecode a? f = Lake.Toml.optDecodeD default a? f
Instances For
If the value is not none
, run the decode action.
If it fails, add the errors to the state and return none
.
Otherwise, return the result in some
.
Equations
- Lake.Toml.optDecode? a? f = Lake.Toml.optDecodeD none a? fun (a : α) => some <$> f a
Instances For
If either action errors, throw the concatenated errors.
Otherwise, if no errors, combine the results with f
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lake.Toml.throwDecodeErrorAt ref msg es = EStateM.Result.error () (es.push { ref := ref, msg := msg })
Instances For
Decode an array of TOML values, merging any errors from the elements into a single array.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- (Lake.Toml.Value.string ref v_2).decodeString = EStateM.Result.ok v_2
- v.decodeString = Lake.Toml.throwDecodeErrorAt v.ref "expected string"
Instances For
Equations
Equations
- Lake.Toml.Value.instDecodeTomlFilePath = { decode := fun (x : Lake.Toml.Value) => System.FilePath.mk <$> Lake.decodeToml x }
Equations
- v.decodeName = do let __do_lift ← v.decodeString match __do_lift.toName with | Lean.Name.anonymous => Lake.Toml.throwDecodeErrorAt v.ref "expected name" | n => pure n
Instances For
Equations
Equations
- (Lake.Toml.Value.integer ref v_2).decodeInt = EStateM.Result.ok v_2
- v.decodeInt = Lake.Toml.throwDecodeErrorAt v.ref "expected integer"
Instances For
Equations
Equations
- (Lake.Toml.Value.integer ref (Int.ofNat v)).decodeNat = EStateM.Result.ok v
- x✝.decodeNat = Lake.Toml.throwDecodeErrorAt x✝.ref "expected nonnegative integer"
Instances For
Equations
Equations
- (Lake.Toml.Value.float ref v_2).decodeFloat = EStateM.Result.ok v_2
- v.decodeFloat = Lake.Toml.throwDecodeErrorAt v.ref "expected float"
Instances For
Equations
Equations
- (Lake.Toml.Value.boolean ref v_2).decodeBool = EStateM.Result.ok v_2
- v.decodeBool = Lake.Toml.throwDecodeErrorAt v.ref "expected boolean"
Instances For
Equations
Equations
- (Lake.Toml.Value.dateTime ref v_2).decodeDateTime = EStateM.Result.ok v_2
- v.decodeDateTime = Lake.Toml.throwDecodeErrorAt v.ref "expected date-time"
Instances For
Equations
Equations
- (Lake.Toml.Value.array ref vs).decodeValueArray = EStateM.Result.ok vs
- v.decodeValueArray = Lake.Toml.throwDecodeErrorAt v.ref "expected array"
Instances For
Equations
- v.decodeArray = do let __do_lift ← v.decodeValueArray Lake.Toml.decodeArray __do_lift
Instances For
Equations
Equations
Instances For
Equations
- (Lake.Toml.Value.table' ref t).decodeTable = EStateM.Result.ok t
- v.decodeTable = Lake.Toml.throwDecodeErrorAt v.ref "expected table"
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- t.decodeValue k ref = match Lake.Toml.RBDict.find? k t with | some a => pure a | x => Lake.Toml.throwDecodeErrorAt ref (toString "missing required key: " ++ toString (Lake.Toml.ppKey k))
Instances For
Equations
- t.decode k ref = do let a ← t.decodeValue k ref Lake.Toml.decodeKeyval k a
Instances For
Equations
- t.decode? k = Option.mapM (fun (v : Lake.Toml.Value) => Lake.Toml.decodeKeyval k v) (Lake.Toml.RBDict.find? k t)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lake.Toml.Table.instDecodeTomlNameMap = { decode := fun (x : Lake.Toml.Value) => do let __do_lift ← x.decodeTable __do_lift.decodeNameMap }
Equations
- t.tryDecode k ref = Lake.Toml.tryDecode (t.decode k ref)
Instances For
Equations
Instances For
Equations
- Lake.Toml.Table.tryDecodeD k default t = Lake.Toml.optDecodeD default (Lake.Toml.RBDict.find? k t) Lake.DecodeToml.decode