Lean2Js.Prelude
The functions an author writes where Lean's own would mean something else #
An author writes ordinary Lean, and most of it means on the JS side what it means in Lean: ++ on a
List concatenates, List.reverse reverses, String.length counts the same characters eval counts.
The functions collected here are the ones where that is not so, and each is here for one of three reasons.
Lean's function computes something else. String.trim strips every Unicode space and String.toUpper
maps ß to SS, which changes the length of the string; the subset strips four characters and folds only
ASCII. Str.trim and Str.upper name what the subset does, so an author's theorem is about the shipped
behaviour rather than about Lean's.
Lean has no partial function to write. Reading past the end of an array traps on the JS side and so
does a substring whose bounds do not fit. A Lean function is total, so Arr.get answers with default
there — the certificate is one-sided, so the answer in the trapping case is never claimed.
Lean's own is recursive. List.take, List.contains and List.flatMap repeat by recursion, and
the walk reads no recursion. The ones collected under @[expand] say the same thing with slice, any
and foldl, and are written out where they are called, so the package ships no function for them.
Opt and Exc hold the Option and Except vocabulary under names of their own rather than adding to
Option and Except. The mark goes only on a declaration this library elaborates, and Option.getD and
Except.map are imported before this file is read; a second Except.map would also be ambiguous with
Lean's under the open Lean2Js an author writes.
Nat is not in the subset, so the functions that count answer with Int.
Two of the types here exist because a Value constructor had no Lean type left to it. Int already
encodes to Int53 and List (String × α) already encodes to an array, so Value.bigint and
Value.dict get BigInt and Dict — wrappers whose only job is to be a different type from the one
that took the encoding first.
Lean2Js.Arr.length
sourceHow many elements, as the Int53 the subset counts in.
Equations
- Lean2Js.Arr.length xs = Int.ofNat xs.length
Instances For
Used by
Lean2Js.Arr.range
sourceThe whole numbers below n, and none of them where n is not positive.
This is the array a body folds over when it has to run a number of times rather than once per element it
was handed. It is the one array whose length a value rather than the syntax decides, so Bound asks that
the program text bound that value -- Arr.range (min (max n 0) 64) -- exactly as it does of a repeat.
Equations
- Lean2Js.Arr.range n = List.map (fun (k : Nat) => ↑k) (List.range n.toNat)
Instances For
Used by
Lean2Js.Arr.get
sourceThe element at an index. An index outside the array traps rather than answering default; what is
written here is what the total function has to say in a case the certificate never reaches.
Equations
- Lean2Js.Arr.get xs i = xs.getD i.toNat default
Instances For
Used by
Lean2Js.Arr.KeyOrd
sourceThe key types the subset orders an array by. le is the order the author reasons with, and
agrees is what ties it to the order the generated code puts the elements in; scalar is what says the
key is one the comparison is defined on, which is what keeps the two sides from parting company on a
value neither order was written for.
Instances
Used by
Lean2Js.Arr.instKeyOrdInt
sourceEquations
- Lean2Js.Arr.instKeyOrdInt = { le := fun (a b : Int) => decide (a ≤ b), agrees := Lean2Js.Arr.instKeyOrdInt._proof_1, scalar := Lean2Js.Arr.instKeyOrdInt._proof_2 }
Used by
Lean2Js.Arr.instKeyOrdString
sourceEquations
- Lean2Js.Arr.instKeyOrdString = { le := fun (a b : String) => compare a b != Ordering.gt, agrees := Lean2Js.Arr.instKeyOrdString._proof_1, scalar := Lean2Js.Arr.instKeyOrdString._proof_2 }
Used by
Lean2Js.Arr.sortByKey
sourceThe elements ordered by their key. List.mergeSort is what the generated code computes too, so what
it proves is what ships: the answer is a permutation of the input, and elements whose keys compare equal
keep the order they came in.
Equations
Instances For
Used by
Lean2Js.Arr.sortByKey_perm
sourceUsed by
Lean2Js.Arr.slice
sourceThe elements from lo up to but not including hi. Bounds that do not fit trap.
Instances For
Used by
Lean2Js.Arr.take
sourceThe first n elements, or all of them where there are fewer.
Equations
- Lean2Js.Arr.take xs n = Lean2Js.Arr.slice xs 0 n
Instances For
Used by
Lean2Js.Arr.drop
sourceEverything after the first n elements.
Equations
- Lean2Js.Arr.drop xs n = Lean2Js.Arr.slice xs n (Lean2Js.Arr.length xs)
Instances For
Used by
Lean2Js.Arr.isEmpty
sourceEquations
- Lean2Js.Arr.isEmpty xs = (Lean2Js.Arr.length xs == 0)
Instances For
Used by
Lean2Js.Arr.contains
sourceEquations
- Lean2Js.Arr.contains xs wanted = xs.any fun (y : α) => y == wanted
Instances For
Used by
Lean2Js.Arr.sum
sourceThe elements added up. Leaving Int53 on the way traps, as the addition does.
Equations
- Lean2Js.Arr.sum xs = List.foldl (fun (running y : Int) => running + y) 0 xs
Instances For
Used by
Lean2Js.Arr.count
sourceHow many elements p holds of.
Equations
- Lean2Js.Arr.count xs p = List.foldl (fun (running : Int) (y : α) => if p y = true then running + 1 else running) 0 xs
Instances For
Used by
The equations to reason with #
Every one of these is written as a foldl or a List.any so that the walk can read it, and neither
shape reduces on the empty array and the one built from :: the way an author's goal needs. These are
the two cases as simp lemmas, so a theorem about a literal array closes without naming List.foldl,
and one about x :: xs peels a single element.
Lean2Js.Arr.length_nil
sourceUsed by
Lean2Js.Arr.length_cons
sourceUsed by
Lean2Js.Arr.isEmpty_nil
sourceUsed by
Lean2Js.Arr.isEmpty_cons
sourceUsed by
Lean2Js.Arr.contains_nil
sourceUsed by
Lean2Js.Arr.contains_cons
sourceUsed by
Lean2Js.Arr.sum_nil
sourceUsed by
Lean2Js.Arr.sum_cons
sourceUsed by
Lean2Js.Arr.count_nil
sourceUsed by
Lean2Js.Arr.count_cons
sourceUsed by
Lean2Js.Arr.head?
sourceThe first element, or none where there is none. Unlike get, this never traps — the empty case is
an answer rather than a read past the end.
Equations
- Lean2Js.Arr.head? xs = if (Lean2Js.Arr.length xs == 0) = true then none else some (Lean2Js.Arr.get xs 0)
Instances For
Used by
Lean2Js.Arr.last?
sourceThe last element, or none where there is none.
Equations
- Lean2Js.Arr.last? xs = if (Lean2Js.Arr.length xs == 0) = true then none else some (Lean2Js.Arr.get xs (Lean2Js.Arr.length xs - 1))
Instances For
Used by
Lean2Js.Arr.flatten
sourceThe arrays run together, in the order they come in.
Equations
- Lean2Js.Arr.flatten xss = List.foldl (fun (running xs : List α) => running ++ xs) [] xss
Instances For
Used by
Lean2Js.Arr.flatMap
sourceEach element replaced by an array, and those run together.
Equations
- Lean2Js.Arr.flatMap xs f = List.foldl (fun (running : List β) (x : α) => running ++ f x) [] xs
Instances For
Used by
Lean2Js.Arr.head?_nil
sourceUsed by
Lean2Js.Arr.head?_cons
sourceUsed by
Lean2Js.Arr.last?_nil
sourceUsed by
Lean2Js.Arr.flatten_nil
sourceUsed by
Lean2Js.Arr.flatten_cons
sourceUsed by
Lean2Js.Arr.flatMap_nil
sourceUsed by
Lean2Js.Arr.flatMap_cons
sourceUsed by
Lean2Js.Str.length
sourceHow many code points, as the Int53 the subset counts in. JS's own .length counts UTF-16 units;
the generated code goes through Array.from so that it counts what this counts.
Equations
Instances For
Used by
Lean2Js.Str.trim
sourceStrips space, tab, carriage return and newline. JS's trim also takes NBSP, the BOM and the line
separators, so an author who wants exactly those four writes this.
Equations
Instances For
Used by
Lean2Js.Str.upper
sourceASCII case folding. String.toUpper is full Unicode and can change the length of the string.
Equations
Instances For
Used by
Lean2Js.Str.lower
sourceASCII case folding. String.toLower is full Unicode.
Equations
Instances For
Used by
Lean2Js.Str.startsWith
sourceEquations
- Lean2Js.Str.startsWith s t = t.toList.isPrefixOf s.toList
Instances For
Used by
Lean2Js.Str.endsWith
sourceEquations
Instances For
Used by
Lean2Js.Str.includes
sourceEquations
Instances For
Used by
Lean2Js.Str.split
sourceSplitting on the empty separator gives back the whole string, where JS's split("") would give the
UTF-16 units.
Equations
- Lean2Js.Str.split s sep = Lean2Js.splitStr s sep
Instances For
Used by
Lean2Js.Str.substring
sourceThe code points from lo up to but not including hi. Bounds that do not fit trap.
Equations
- Lean2Js.Str.substring s lo hi = String.ofList (List.take (hi - lo).toNat (List.drop lo.toNat s.toList))
Instances For
Used by
Lean2Js.Str.toInt?
sourceReads back what Int53.toString prints, and nothing else. "007", "+5", " 5" and "-0" are
refused along with everything outside the Int53 range, because none of them is what the printer would
have written. JS's own Number() reads all four.
Equations
Instances For
Used by
Lean2Js.Str.indexOf?
sourceWhere t first sits in s, counted in code points, or none when it does not sit there at all.
The empty needle sits at 0. JS's own indexOf counts UTF-16 units and answers -1 for absence.
Equations
Instances For
Used by
Lean2Js.Str.join
sourceThe strings in order with sep between them, the way JS's own Array.prototype.join puts it
together. An empty list joins to the empty string.
Equations
- Lean2Js.Str.join xs sep = Lean2Js.joinStr xs sep
Instances For
Used by
Lean2Js.Str.replace
sourceEvery occurrence of pat, not just the first: this is JS's replaceAll, where JS's replace takes
only the first. An empty pat leaves s as it is, where replaceAll("", r) inserts at every position.
Equations
- Lean2Js.Str.replace s pat rep = Lean2Js.Str.join (Lean2Js.Str.split s pat) rep
Instances For
Used by
Lean2Js.Str.repeat
sources written n times over, counted in code points the way Str.length counts them. A count of
zero or less gives the empty string, where JS's own repeat throws on a negative one. A result longer
than an Int53 traps, the same bound Str.length lives under.
Equations
- Lean2Js.Str.repeat s n = Lean2Js.repeatStr s n.toNat
Instances For
Used by
Lean2Js.Str.isEmpty
sourceEquations
- Lean2Js.Str.isEmpty s = (Lean2Js.Str.length s == 0)
Instances For
Used by
Lean2Js.Str.padStart
sources widened to n code points by writing pad in front of it, cut to fit exactly. A width s
already reaches, and an empty pad, leave s as it is. JS's own padStart counts UTF-16 units, so it
pads astral text short.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
The equations to reason with #
Str.join is the one that needs saying. It is written from joinStr, which is written from joinFrom,
and unfolding it walks a goal one private name at a time to a fold whose accumulator has already eaten the
first element. What an author wants is the list peeled from the front, which is what these three give.
Lean2Js.Str.length_empty
sourceUsed by
Lean2Js.Str.isEmpty_empty
sourceUsed by
Lean2Js.Str.join_nil
sourceUsed by
Lean2Js.Str.join_singleton
sourceUsed by
Lean2Js.Str.join_cons
sourceUsed by
Lean2Js.Str.repeat_zero
sourceUsed by
Lean2Js.Str.repeat_nonpos
sourceUsed by
Lean2Js.Str.padStart_of_le
sourceThe width already reached is the case a padding theorem starts from, and the guard is what says so.
Used by
Lean2Js.Int53.div
sourceTruncating division, which is what the generated Math.trunc performs. Lean's / on Int rounds
towards negative infinity, so -7 / 2 is -4 there and -3 here. A zero divisor traps.
Equations
- Lean2Js.Int53.div a b = a.tdiv b
Instances For
Used by
Lean2Js.Int53.mod
sourceThe remainder that goes with div. A zero divisor traps.
Equations
- Lean2Js.Int53.mod a b = a.tmod b
Instances For
Used by
Lean2Js.Int53.abs
sourceEquations
- Lean2Js.Int53.abs a = ↑a.natAbs
Instances For
Used by
Lean2Js.Int53.divFloor
sourceDivision rounding towards negative infinity, where div rounds towards zero: divFloor (-7) 2 is
-4 and div (-7) 2 is -3. A zero divisor traps, as div does.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Int53.divCeil
sourceDivision rounding towards positive infinity.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Int53.divRound
sourceDivision rounding a half away from zero, which is how an amount in minor units is rounded where
nothing says otherwise: divRound 5 2 is 3 and divRound (-5) 2 is -3. The remainder is compared
against what is left of the divisor rather than doubled, so a divisor near the top of the range decides
the same way as any other rather than trapping on the way to the answer.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Int53.toString
sourceThe decimal spelling. JS's String(n) falls back to exponent notation only at 1e21, which is above
the Int53 range, so the two agree on every Int53.
Equations
Instances For
Used by
The civil calendar #
Days counted from 1970-01-01, and the civil date of a day, by Howard Hinnant's algorithms. Both are
integer arithmetic and nothing else, which is why the calendar can be in the subset where Date cannot:
a date is an amount of days, an instant is an amount of milliseconds, and neither reads a clock or a
zone. The calendar is proleptic Gregorian — carried backwards past its adoption rather than switching,
which is what an epoch day count is everywhere.
Each of year, month and day reads the whole date out of the day number, so asking for all three
writes the arithmetic out three times. There is no tuple in the subset to hand back instead.
Lean2Js.Cal.fromCivil
sourceThe day a civil date falls on, counting from 1970-01-01, which is day zero. A month outside 1..12 or a day outside the month is not refused: the arithmetic carries it, so 2026-13-01 is 2027-01-01.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Cal.era
sourceThe four-hundred-year era a day falls in, counted from the one holding 0000-03-01. Written out because the three readings below each need it, and the subset has nothing to share it with.
Equations
Instances For
Used by
Lean2Js.Cal.dayOfEra
sourceThe day's place inside its era, in 0..146096.
Equations
Instances For
Used by
Lean2Js.Cal.yearOfEra
sourceThe day's year inside its era, in 0..399.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Cal.dayOfYear
sourceThe day's place inside its year, counting from the first of March, in 0..365.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Cal.monthOfYear
sourceThe month in March-first numbering, in 0..11. January and February are 10 and 11, which is what makes a leap day the last day of the year and the arithmetic above carry no special case.
Equations
- Lean2Js.Cal.monthOfYear days = Lean2Js.Int53.div (5 * Lean2Js.Cal.dayOfYear days + 2) 153
Instances For
Used by
Lean2Js.Cal.year
sourceThe civil year the day falls in.
Equations
- Lean2Js.Cal.year days = Lean2Js.Cal.yearOfEra days + Lean2Js.Cal.era days * 400 + if Lean2Js.Int53.div (5 * Lean2Js.Cal.dayOfYear days + 2) 153 ≥ 10 then 1 else 0
Instances For
Used by
Lean2Js.Cal.month
sourceThe civil month, 1..12.
Equations
- Lean2Js.Cal.month days = Lean2Js.Cal.monthOfYear days + if Lean2Js.Cal.monthOfYear days < 10 then 3 else -9
Instances For
Used by
Lean2Js.Cal.day
sourceThe civil day of the month, 1..31.
Equations
- Lean2Js.Cal.day days = Lean2Js.Cal.dayOfYear days - Lean2Js.Int53.div (153 * Lean2Js.Int53.div (5 * Lean2Js.Cal.dayOfYear days + 2) 153 + 2) 5 + 1
Instances For
Used by
Lean2Js.Cal.weekday
sourceThe day of the week, 0 for Sunday through 6 for Saturday. Day zero is a Thursday.
Equations
- Lean2Js.Cal.weekday days = days + 4 - 7 * Lean2Js.Int53.divFloor (days + 4) 7
Instances For
Used by
Lean2Js.Cal.isLeapYear
sourceWhether a year carries a leap day, by the Gregorian rule.
Equations
- Lean2Js.Cal.isLeapYear year = if (Lean2Js.Int53.mod year 400 == 0) = true then true else if (Lean2Js.Int53.mod year 100 == 0) = true then false else Lean2Js.Int53.mod year 4 == 0
Instances For
Used by
Lean2Js.Cal.daysInMonth
sourceHow many days a month holds, read as the distance to the first of the next month so that it cannot
disagree with fromCivil about a leap February.
Equations
- Lean2Js.Cal.daysInMonth year month = Lean2Js.Cal.fromCivil (if month ≥ 12 then year + 1 else year) (if month ≥ 12 then 1 else month + 1) 1 - Lean2Js.Cal.fromCivil year month 1
Instances For
Used by
Lean2Js.Cal.dayOfInstant
sourceThe day an instant falls in, an instant being milliseconds from the epoch. An instant before the
epoch belongs to the day it is inside, which is divFloor and not div.
Equations
- Lean2Js.Cal.dayOfInstant ms = Lean2Js.Int53.divFloor ms 86400000
Instances For
Used by
Lean2Js.Cal.instantOfDay
sourceThe first instant of a day.
Equations
- Lean2Js.Cal.instantOfDay days = days * 86400000
Instances For
Used by
Lean2Js.Opt.getD
sourceEquations
- Lean2Js.Opt.getD (some a) dflt = a
- Lean2Js.Opt.getD none dflt = dflt
Instances For
Used by
Lean2Js.Opt.map
sourceEquations
- Lean2Js.Opt.map (some a) f = some (f a)
- Lean2Js.Opt.map none f = none
Instances For
Used by
Lean2Js.Opt.getD_some
sourceUsed by
Lean2Js.Opt.getD_none
sourceUsed by
Lean2Js.Opt.map_some
sourceUsed by
Lean2Js.Opt.map_none
sourceUsed by
Lean2Js.Exc.getD
sourceEquations
- Lean2Js.Exc.getD (Except.ok a) dflt = a
- Lean2Js.Exc.getD (Except.error a) dflt = dflt
Instances For
Used by
Lean2Js.Exc.map
sourceEquations
- Lean2Js.Exc.map (Except.ok a) f = Except.ok (f a)
- Lean2Js.Exc.map (Except.error a) f = Except.error a
Instances For
Used by
Lean2Js.Exc.mapError
sourceEquations
- Lean2Js.Exc.mapError (Except.ok a) f = Except.ok a
- Lean2Js.Exc.mapError (Except.error a) f = Except.error (f a)
Instances For
Used by
Lean2Js.Exc.toOption
sourceWhat the check accepted, with why it refused dropped.
Equations
Instances For
Used by
Lean2Js.Exc.getD_ok
sourceUsed by
Lean2Js.Exc.getD_error
sourceUsed by
Lean2Js.Exc.map_ok
sourceUsed by
Lean2Js.Exc.map_error
sourceUsed by
Lean2Js.Exc.mapError_ok
sourceUsed by
Lean2Js.Exc.mapError_error
sourceUsed by
Lean2Js.Exc.toOption_ok
sourceUsed by
Lean2Js.Exc.toOption_error
sourceUsed by
Lean2Js.BigInt
sourceThe subset's arbitrary-precision integer. Int is already the one that has to fit in a JS number, so
the one that does not is a wrapper: the two are told apart by their type, never by their values.
Instances For
Used by
Lean2Js.instDecidableEqBigInt
sourceUsed by
Lean2Js.instDecidableEqBigInt.decEq
sourceEquations
Instances For
Used by
Lean2Js.instInhabitedBigInt
sourceEquations
Used by
Lean2Js.instReprBigInt
sourceEquations
- Lean2Js.instReprBigInt = { reprPrec := Lean2Js.instReprBigInt.repr }
Used by
Lean2Js.instReprBigInt.repr
sourceEquations
- Lean2Js.instReprBigInt.repr x✝ prec✝ = Std.Format.bracket "{ " (Std.Format.nil ++ Std.Format.text "val" ++ Std.Format.text " := " ++ (Std.Format.nest 7 (repr x✝.val)).group) " }"
Instances For
Used by
Lean2Js.BigInt.instBEq
source== is the subset's equality, so it is the one on the value rather than the one DecidableEq
would derive through the wrapper.
Equations
- Lean2Js.BigInt.instBEq = { beq := fun (a b : Lean2Js.BigInt) => a.val == b.val }
Used by
Lean2Js.BigInt.instReflBEq
sourceUsed by
Lean2Js.BigInt.instLawfulBEq
sourceUsed by
Lean2Js.BigInt.instAdd
sourceEquations
- Lean2Js.BigInt.instAdd = { add := fun (a b : Lean2Js.BigInt) => { val := a.val + b.val } }
Used by
Lean2Js.BigInt.instSub
sourceEquations
- Lean2Js.BigInt.instSub = { sub := fun (a b : Lean2Js.BigInt) => { val := a.val - b.val } }
Used by
Lean2Js.BigInt.instMul
sourceEquations
- Lean2Js.BigInt.instMul = { mul := fun (a b : Lean2Js.BigInt) => { val := a.val * b.val } }
Used by
Lean2Js.BigInt.instNeg
sourceEquations
- Lean2Js.BigInt.instNeg = { neg := fun (a : Lean2Js.BigInt) => { val := -a.val } }
Used by
Lean2Js.BigInt.instLT
sourceEquations
- Lean2Js.BigInt.instLT = { lt := fun (a b : Lean2Js.BigInt) => a.val < b.val }
Used by
Lean2Js.BigInt.instLE
sourceEquations
- Lean2Js.BigInt.instLE = { le := fun (a b : Lean2Js.BigInt) => a.val ≤ b.val }
Used by
Lean2Js.BigInt.instDecidableLt
sourceEquations
- a.instDecidableLt b = a.val.decLt b.val
Used by
Lean2Js.BigInt.instDecidableLe
sourceEquations
- a.instDecidableLe b = a.val.decLe b.val
Used by
Lean2Js.BigInt.instOfNat
sourceUsed by
Lean2Js.BigInt.div
sourceTruncating division, as on Int53. A zero divisor traps.
Instances For
Used by
Lean2Js.BigInt.mod
sourceInstances For
Used by
Lean2Js.BigInt.abs
sourceInstances For
Used by
Lean2Js.Dict
sourceA Map on the JS side. The entries are a list rather than a set because iteration order is
observable through keys, so the two sides have to agree on it: a write to a key already present leaves
it where it is, and a write to a new one appends.
Instances For
Used by
Lean2Js.Dict.ofList
sourceEquations
- Lean2Js.Dict.ofList entries = { entries := entries }
Instances For
Used by
Lean2Js.Dict.get
sourceEquations
Instances For
Used by
Lean2Js.Dict.has
sourceInstances For
Used by
Lean2Js.Dict.set
sourceWriting a key already present leaves it where it is; writing a new one appends.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Dict.erase
sourceInstances For
Used by
Lean2Js.Dict.keys
sourceInstances For
Used by
Lean2Js.Dict.values
sourceInstances For
Used by
Lean2Js.Dict.size
sourceHow many entries, as the Int53 the subset counts in.
Instances For
Used by
Lean2Js.Dict.getD
sourceWhat k is bound to, or dflt where it is bound to nothing.
Equations
- d.getD k dflt = Lean2Js.Opt.getD (d.get k) dflt
Instances For
Used by
Lean2Js.Dict.ofPairs
sourceAn array indexed by a key read off each element. Where two elements give the same key the later one
wins, and keeps the place the earlier one took. ofList takes literal keys; this one takes computed
ones.
Equations
- Lean2Js.Dict.ofPairs xs key = List.foldl (fun (d : Lean2Js.Dict α) (x : α) => d.set (key x) x) (Lean2Js.Dict.ofList []) xs
Instances For
Used by
Lean2Js.Dict.Obj
sourceThe same dictionary as Dict, declared to cross the boundary as a plain object rather than as a
Map. Inside the module the two are one thing — a value of either is a Value.dict, and every
operation runs on the same Map — so what the constructor decides is only what a consumer meets:
JSON.stringify of a Map is {}, and what a consumer stringifies is a return value.
ofList writes one out key by key, and set and erase give back the spelling they were handed, so a
declaration can build one as readily as it can be handed one.
Instances For
Used by
Lean2Js.Dict.Obj.ofList
sourceEquations
- Lean2Js.Dict.Obj.ofList entries = { entries := entries }
Instances For
Used by
Lean2Js.Dict.Obj.get
sourceEquations
Instances For
Used by
Lean2Js.Dict.Obj.has
sourceInstances For
Used by
Lean2Js.Dict.Obj.set
sourceWriting a key already present leaves it where it is; writing a new one appends.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Dict.Obj.erase
sourceInstances For
Used by
Lean2Js.Dict.Obj.keys
sourceInstances For
Used by
Lean2Js.Dict.Obj.values
sourceInstances For
Used by
Lean2Js.Dict.Obj.size
sourceHow many entries, as the Int53 the subset counts in.
Instances For
Used by
Lean2Js.Dict.Obj.getD
sourceWhat k is bound to, or dflt where it is bound to nothing.
Equations
- d.getD k dflt = Lean2Js.Opt.getD (d.get k) dflt
Instances For
Used by
Lean2Js.Dict.Obj.ofPairs
sourceAn array indexed by a key read off each element, at this spelling. Dict.ofPairs is the same over a
Map.
Equations
- Lean2Js.Dict.Obj.ofPairs xs key = List.foldl (fun (d : Lean2Js.Dict.Obj α) (x : α) => d.set (key x) x) (Lean2Js.Dict.Obj.ofList []) xs
Instances For
Used by
Lean2Js.encEntry
sourceThe entry an encoded Dict carries for one of its own.
Equations
Instances For
Used by
Lean2Js.Enc.keys_encEntry
sourceThe keys survive the encoding untouched, which is what lets the entry check ask about the author's own dictionary rather than about the encoded one.
Used by
Lean2Js.Enc.instDict
sourceEquations
- One or more equations did not get rendered due to their size.
Used by
Lean2Js.Enc.ty_dict
sourceUsed by
Lean2Js.Enc.toValue_dict
sourceUsed by
Lean2Js.Enc.instObj
sourceEquations
- One or more equations did not get rendered due to their size.
Used by
Lean2Js.Enc.ty_dictObj
sourceUsed by
Lean2Js.Enc.toValue_dictObj
sourceUsed by
Lean2Js.Enc.instBigInt
sourceEquations
- One or more equations did not get rendered due to their size.