Lean2Js.Vectors
The inputs of the differential test and the values eval must return #
Builds the inputs of the differential test and the values eval is expected to return. What agreement
means, and the file both checkers read, are in Lean2Js/Agree.lean: saying what the generated code must
hand back needs the encoding, and the encoding is that module's subject.
Traps are encoded as expected values too. Division by zero and Int53 overflow are the central design decision for lining JS and Lean up, so "that it throws" is itself the behaviour we want to check.
Lean2Js.bmpMax
sourceThe last character of the BMP. JS's .length counts UTF-16 units, so past here it splits from
Lean.
Equations
- Lean2Js.bmpMax = String.singleton (Char.ofNat 65535)
Instances For
Used by
Lean2Js.astral
sourceA character outside the BMP. In JS it becomes a surrogate pair, two units long.
Equations
- Lean2Js.astral = String.singleton (Char.ofNat 65536)
Instances For
Used by
Lean2Js.dictKeyPool
sourceThe keys a generated dictionary uses. They are drawn from the strings a String parameter is offered,
so a lookup in one of these dictionaries can actually hit.
Instances For
Used by
Lean2Js.namedDepth
sourceHow many declared types deep a generated value goes. A type that names itself has no finite set of
values, so the generator stops expanding one this far down and the constructors that reach it drop out —
which for a well-founded inductive leaves the ones that do not, and those are its base cases.
Deep enough that no type which does not name itself is cut short: tyDescBudget bounds the expansion of
such a type by the number of declared types, and nothing here goes further than the descriptor does.
Equations
- Lean2Js.namedDepth p = p.types.length + 1
Instances For
Used by
Lean2Js.edgeCases
sourceAlways steps just inside and just outside the boundary. Overflow and rounding break nowhere else.
Used by
Lean2Js.ArgShape
sourceHow an argument is written on the JS side. encodeValue puts the key the constructor's name is
carried under first and the declared fields in declared order, but the .d.ts names no order and
tolerates keys the type does not declare, so both of those readings need vectors of their own. Neither
is a Value: the perturbation rides alongside the argument and is applied to its encoding.
asObject is not a perturbation of the encoding but a second encoding: the argument read through the
type it was declared at, so a dictionary the type says crosses as a plain object is written as one. It
cannot be a perturbation, because whether a dictionary crosses as an object is the declared type's to
say — turning every Map into an object would be refused at a Dict parameter.
Instances For
Used by
Lean2Js.instBEqArgShape.beq
sourceEquations
- Lean2Js.instBEqArgShape.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Used by
Lean2Js.instBEqArgShape
sourceEquations
Used by
Lean2Js.instReprArgShape.repr
sourceEquations
- Lean2Js.instReprArgShape.repr Lean2Js.ArgShape.canonical prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.ArgShape.canonical")).group prec✝
- Lean2Js.instReprArgShape.repr Lean2Js.ArgShape.reversed prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.ArgShape.reversed")).group prec✝
- Lean2Js.instReprArgShape.repr Lean2Js.ArgShape.extraKey prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.ArgShape.extraKey")).group prec✝
- Lean2Js.instReprArgShape.repr Lean2Js.ArgShape.asObject prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.ArgShape.asObject")).group prec✝
Instances For
Used by
Lean2Js.instReprArgShape
sourceEquations
- Lean2Js.instReprArgShape = { reprPrec := Lean2Js.instReprArgShape.repr }
Used by
Lean2Js.instInhabitedArgShape
sourceEquations
Used by
Lean2Js.ArgShape.render
sourceEquations
- Lean2Js.ArgShape.canonical.render = "canonical"
- Lean2Js.ArgShape.reversed.render = "reversed"
- Lean2Js.ArgShape.extraKey.render = "extraKey"
- Lean2Js.ArgShape.asObject.render = "asObject"
Instances For
Used by
Lean2Js.extraKeyName
sourceThe key ArgShape.extraKey adds. It is not an identifier, so no program can declare a field by that
name and the key is undeclared whatever the program is.
Equations
- Lean2Js.extraKeyName = "not a field"
Instances For
Used by
Lean2Js.TestVector
sourceThe types the parameters were declared at, in order. How an argument is written can depend on its type — a dictionary at a
Dict.Objparameter crosses as a plain object — so the types travel with the vector rather than being looked up by name again at each reader.The declaration's return type. The entry hands its result back through it, so it is what decides whether a dictionary comes back as a
Mapor as a plain object, and both checkers read it rather than assuming the encoding aValuehas on its own.
Instances For
Used by
Lean2Js.TestVector.shapeAt
sourceEquations
- v.shapeAt i = v.shapes.getD i Lean2Js.ArgShape.canonical
Instances For
Used by
Lean2Js.TestVector.writtenArgs
sourceEach argument with the type it was declared at and the way this vector says to write it. Pairing the three lists once here is what keeps a reader from having to default a type it could not find.
Equations
Instances For
Used by
Lean2Js.Value.toJson
sourceThe key a constructor's name is carried under travels with the vector: the script on Node builds the argument the way the generated code expects it, and that is the type's own key rather than a fixed one.
Used by
Lean2Js.vectorsFor
sourceEquations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.allTestVectors
sourceEquations
- One or more equations did not get rendered due to their size.