Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflection: Use Telescope for getContext, inContext, and extendContext #5715

Closed
L-TChen opened this issue Dec 30, 2021 · 2 comments
Closed
Assignees
Labels
reflection Elaborator reflection, macros, tactic arguments
Milestone

Comments

@L-TChen
Copy link
Member

L-TChen commented Dec 30, 2021

Currently, getContext and inContext only returns and takes a list of Arg Type without a name, and internally all variables are named x:

extendCxt :: Arg R.Type -> UnquoteM a -> UnquoteM a
extendCxt a m = do
a <- locallyReduceAllDefs $ liftTCM $ traverse (isType_ <=< toAbstract_) a
liftU1 (addContext ("x" :: String, domFromArg a :: Dom Type)) m

In order to print terms nicely, e.g. using debugPrint or typeError with termErr, I propose that they all should use Telescope (i.e. List (Σ String λ _ → Arg Type)) instead. For the same reason, extendContext should take an extra argument of type String in order to give a name to the variable introduced to the context.

It would be a breaking change but this change allows programmers to easily print not only understandable but also more precise type information during macro expansion.

@L-TChen L-TChen added the reflection Elaborator reflection, macros, tactic arguments label Dec 30, 2021
@L-TChen L-TChen self-assigned this Dec 30, 2021
@L-TChen L-TChen changed the title [ reflection ] Proposal: Use Telescope for getContext, inContext, and extendContext Proposal: Use Telescope for getContext, inContext, and extendContext Dec 30, 2021
@L-TChen L-TChen added this to the 2.6.3 milestone Dec 30, 2021
@andreasabel
Copy link
Member

andreasabel commented Mar 26, 2022

Note: this breaks master of cubical:

@andreasabel andreasabel changed the title Proposal: Use Telescope for getContext, inContext, and extendContext Reflection: Use Telescope for getContext, inContext, and extendContext Oct 25, 2022
@asr asr changed the title Reflection: Use Telescope for getContext, inContext, and extendContext Reflection: Use Telescope for getContext, inContext, and extendContext Nov 2, 2022
@asr
Copy link
Member

asr commented Nov 2, 2022

I removed a trailing whitespace in the title.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reflection Elaborator reflection, macros, tactic arguments
Projects
None yet
Development

No branches or pull requests

3 participants