You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this way the APIs can read back not only a term but also the context of binders under which it occurs. This requires the user to
systematically add a decl clause when moving under a binder, that is p (lam S TY F) :- pi x\ decl x S TY => ..F x...
Wish
This piece of info (the link between Lam's arguments and Decl) would also be useful in the implementation of spilling, which turns out to be very useful in Coq-Elpi and Hierarchy Builder.
For example:
main:- (pix\ declx"x"bool=>some-pred x (Spill1x)), T=lam"x"boolx\ (Spill1x).
so that some-pred can call typecheck correctly (which requires the context entry decl x ... to be present).
Mock up
The proposal (up to syntax) would be to equip a type declaration with the piece of info that is attached to the ML code above, eg
typelamstring -> ty -> (term --(s\t\x\ declxst)-->term) ->term.
Alternative & discussion
A "cheap" but also not 100% satisfactory alternative proposed by Dale was to have one special term constructor called binder.
In this way the ADT for terms would be
typedeclstring -> ty -> t -> prop.typeappt -> t -> t.type binder (t -> prop) -> (t -> t) -> t.
then lam "x" bool x\ .. would be represented as binder (decl "x" bool) x\ ... and the idiom to cross it would be p (binder B F) :- pi x\ B x => .. F x. In this setting the spilling problem is solved, since when one spills across binder he can just collect its first argument in order to build the context for the spilled computation.
I'm not in love with this because there is a little encoding step that is visible. Eg. in Coq we have 4+ binders (fun, prod, let and fix) and all but let create the same context entry so one would need to pass to binder some extra info, like "lam", and then you really start to see the encoding. Still this proposal clarifies very well what I'd like, it's just that I'd like the encoding to be performed behind the scenes. Also, then .. --(..)--> .. function space constructor can be used by a linter/checker to tell the user "hey, you forgot to use => after pi (if F has type .. --(C)--> .. then F x needs x to be used in a context where C x => is there.
Context
When working at the ppx to synthesize the glue code, it felt natural to link a "context" data type to the one of a data type with binders. Eg
In this way the APIs can read back not only a term but also the context of binders under which it occurs. This requires the user to
systematically add a
decl
clause when moving under a binder, that isp (lam S TY F) :- pi x\ decl x S TY => ..F x..
.Wish
This piece of info (the link between
Lam
's arguments andDecl
) would also be useful in the implementation of spilling, which turns out to be very useful in Coq-Elpi and Hierarchy Builder.For example:
The code after spilling should look like
so that
some-pred
can calltypecheck
correctly (which requires the context entrydecl x ...
to be present).Mock up
The proposal (up to syntax) would be to equip a
type
declaration with the piece of info that is attached to the ML code above, egAlternative & discussion
A "cheap" but also not 100% satisfactory alternative proposed by Dale was to have one special term constructor called
binder
.In this way the ADT for terms would be
then
lam "x" bool x\ ..
would be represented asbinder (decl "x" bool) x\ ...
and the idiom to cross it would bep (binder B F) :- pi x\ B x => .. F x
. In this setting the spilling problem is solved, since when one spills acrossbinder
he can just collect its first argument in order to build the context for the spilled computation.I'm not in love with this because there is a little encoding step that is visible. Eg. in Coq we have 4+ binders (
fun
,prod
,let
andfix
) and all butlet
create the same context entry so one would need to pass tobinder
some extra info, like "lam", and then you really start to see the encoding. Still this proposal clarifies very well what I'd like, it's just that I'd like the encoding to be performed behind the scenes. Also, then.. --(..)--> ..
function space constructor can be used by a linter/checker to tell the user "hey, you forgot to use=>
afterpi
(ifF
has type.. --(C)--> ..
thenF x
needsx
to be used in a context whereC x =>
is there.CC @CohenCyril
The text was updated successfully, but these errors were encountered: