Lean2Js.Enc
Where an ordinary Lean type sits inside Value #
eval answers with a Value, so a certificate about an author's def has to say which Value the
def's result is. Enc is that correspondence: one instance per type an author may write, carrying the
subset type it lands in, the encoding, and the decoding that shows the encoding does not fold two terms
into one.
The entry check is not a law of the class. toValue is total and the boundary is not — Enc Int
encodes every Int, including the ones past Int53 that Decl.decl_refuses turns away. So hasTy holds
only of the values accepts admits, and accepts is what an author sees as a hypothesis on their shipped
theorem. A type whose encoding cannot reach outside its subset type carries accepts _ _ := True and the
hypothesis disappears.
Value.bigint and Value.dict are instanced in Lean2Js/Prelude.lean rather than here: both need a
Lean type that is not already spoken for, since Int encodes to Int53 and List (String × α) would be
an array. Value.fn gets none at all — it names a declaration, and no Lean function value knows which
declaration it is.
Lean2Js.Enc
sourceHow a Lean type is carried across the boundary.
What the boundary asks of the program and the value before
toValue amay cross.
Instances
Used by
The scalars #
Lean2Js.Enc.instBool
sourceEquations
- One or more equations did not get rendered due to their size.
Used by
Lean2Js.Enc.ty_bool
sourceUsed by
Lean2Js.Enc.toValue_bool
sourceUsed by
Lean2Js.Enc.instInt
sourceEquations
- One or more equations did not get rendered due to their size.
Used by
Lean2Js.Enc.ty_int
sourceUsed by
Lean2Js.Enc.toValue_int
sourceUsed by
Lean2Js.Enc.instUInt32
sourceEquations
- One or more equations did not get rendered due to their size.
Used by
Lean2Js.Enc.ty_uint32
sourceUsed by
Lean2Js.Enc.toValue_uint32
sourceUsed by
Lean2Js.Enc.instString
sourceEquations
- One or more equations did not get rendered due to their size.
Used by
Lean2Js.Enc.ty_string
sourceUsed by
Lean2Js.Enc.toValue_str
sourceUsed by
Lean2Js.Enc.toValue_inj
sourceNo two terms share an encoding. ofValue recovers the term, so a type's Enc already says this;
what it takes to use it is naming the step.
Used by
Lean2Js.Enc.EncBEq
sourceThe types the subset compares for equality. eval compares encodings and the author writes == on
their own type, so the two agree exactly when the encoding neither folds two terms together nor splits
one apart. It is a class of its own rather than a law of Enc because a type with no BEq has nothing
to state.
Instances
Used by
Lean2Js.Enc.instEncBEqOfLawfulBEq
sourceInjectivity is one half; the other is that both ==s decide equality rather than something coarser.
An author's own type reaches this by deriving DecidableEq, which is where its LawfulBEq comes from.
Used by
The shapes built out of another type #
Lean2Js.Enc.instOption
sourceEquations
- One or more equations did not get rendered due to their size.
Used by
The subset type is normalised the way the scalars are, because a declaration's parameter carries it
as this projection. The encoding is not: nothing in the subset's own forms needs it rewritten, and what
does is a match on one, whose arm has to reach the tag the pattern tests.
Lean2Js.Enc.ty_option
sourceUsed by
Lean2Js.Enc.toValue_none
sourceUsed by
Lean2Js.Enc.toValue_some
sourceUsed by
Lean2Js.Enc.instExcept
sourceEquations
- One or more equations did not get rendered due to their size.
Used by
Lean2Js.Enc.ty_except
sourceUsed by
Lean2Js.Enc.toValue_ok
sourceUsed by
Lean2Js.Enc.toValue_error
sourceUsed by
Lean2Js.Enc.hasFieldTys_cons_of
sourceOne field of an object, checked against one field of the declared type. The value and its type are
taken as they are rather than through Enc, which is what a field whose type is the one being declared
needs: that type has no instance yet where its own encoding is being written.
Used by
Lean2Js.Enc.hasFieldTys_toValue
sourceOne field of a constructor, for the instance a deriving Enc writes: the entry check on an object
is the checks on its fields, and each field's is its own Enc's.
Used by
Lean2Js.Enc.instList
sourceEquations
- One or more equations did not get rendered due to their size.