Skip to content

Re #3606: Instantiate blocking metas when displaying types and constraints - #3723

Merged
Saizan merged 9 commits into
agda:masterfrom
Saizan:instantiate-blocking
May 9, 2019
Merged

Saizan merged 9 commits into
agda:masterfrom
Saizan:instantiate-blocking

Conversation

@Saizan

@Saizan Saizan commented Apr 26, 2019

Copy link
Copy Markdown
Collaborator

This should be a nice companion to #3716

I'd like some feedback, considering the changes in the output.

It does leave "agda2-show-constraints" untouched, as I figured that could be useful for the experts and debugging.

@jespercockx

Copy link
Copy Markdown
Member

Looks very good to me. The "blocked" constraints are almost never useful to me anyway: my strategy is usually to look for the constraints that are not blocked on anything else, reload the file, and then repeat (see also #3654).

@Saizan

Saizan commented Apr 29, 2019

Copy link
Copy Markdown
Collaborator Author

Yeah, what you really want is to see the problems they are blocked on, so you can tell Agda how to solve those.

@nad

nad commented Apr 29, 2019

Copy link
Copy Markdown
Collaborator

I have some code for which "Show goals" displays four constraints, all related to ?0. However, when I go to the corresponding hole and use "Goal type and context" I only get two of the constraints. When I use "Show constraints" I can see that these two constraints actually mention ?0, whereas the others don't. I'd like to see all four constraints when I use "Goal type and context".

@jespercockx

Copy link
Copy Markdown
Member

How exactly are these other two constraints related to the hole? What we need is a clear criterion for when a constraint is related to a hole, then we could use it to replace the current approximation using mentionsMeta

@Saizan

Saizan commented Apr 29, 2019

Copy link
Copy Markdown
Collaborator Author

I propose that the criterion should be "they mention the meta for the interaction point when instantiated with stInstantiateBlocking = True".

If @nad is seeing them as referring to ?0 in "Show Goals" then such an instantiation should expose the meta corresponding to ?0 in them.

@Saizan

Saizan commented Apr 29, 2019

Copy link
Copy Markdown
Collaborator Author

I will rebase and make that change.

@Saizan
Saizan force-pushed the instantiate-blocking branch from efa72fc to 9bbcebb Compare April 29, 2019 15:47
@Saizan

Saizan commented Apr 29, 2019

Copy link
Copy Markdown
Collaborator Author

@nad let me know if you get all four constraints in "Goal type and context" now.

@nad

nad commented Apr 30, 2019

Copy link
Copy Markdown
Collaborator

I tried with some other code, and could not reproduce the problems described above.

@Saizan
Saizan requested review from UlfNorell and andreasabel May 1, 2019 09:17
@Saizan
Saizan force-pushed the instantiate-blocking branch from 9bbcebb to 2416385 Compare May 8, 2019 07:24
@Saizan
Saizan merged commit 0ebc740 into agda:master May 9, 2019
-- in an irrelevant context. Basically, an internal
-- version of the irrelevance axiom @.irrAx : .A -> A@.
| Dummy String
| Dummy String Elims

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you forget to update the documentation?

@andreasabel

Copy link
Copy Markdown
Member

I don't think it is good for the maintainability of Agda if core invariants are diluted for the sake of a simpler implementation of a UX feature. Crashes are reported further from the point of causation with the softFailure mechanism. This makes it harder to debug issues like #3843.

There should be other ways to achieve what you want. Some ideas:

  • Parametrize the Substitution mechanism (e.g. by a type class constraint) so that it fails hard in the usual circumstances but fails soft when you want it for interaction purposes.
  • Only perform substitution that can lead to ill-typed terms on the fly during printing (@jespercockx idea).

Maybe you have another idea...

@Saizan

Saizan commented Jul 5, 2019

Copy link
Copy Markdown
Collaborator Author

I see your concerns, I figured that an unexpected Dummy would still be caught pretty early, but it seems like it made it all the way through to checkInternal which is indeed late.

We also want to e.g. do the mentionsMeta check on the instantiated constraints, so we need this ill-typed substitution in two places already, and not just right before printing, so I'd rather have a parametrized Substitution.

I will try and see if I can make it work by using a newtype of Term otherwise we can add a boolean flag to applySubst. I'll look into it.

Saizan added a commit to Saizan/agda that referenced this pull request Jul 5, 2019
Saizan added a commit that referenced this pull request Jul 8, 2019
Term's applyE goes back to throwing __IMPOSSIBLE__ for ill-typed redexes.

We have a newtype BraveTerm to just build Dummies instead.

Re #1623: Now agsy restores fields in constructors.
@jespercockx

Copy link
Copy Markdown
Member

I don't understand why Sort is now parametrized over the type of Term. I was just trying to push my fix to #3859 but now I get conflicts in the definition of Sort :(

@jespercockx

Copy link
Copy Markdown
Member

Also, what is the stuff with coerce in Substitute.hs? Is it some deriving-via magic? I thought that wasn't supported yet in 8.0?

@jespercockx

Copy link
Copy Markdown
Member

I think now that Sort is parametrized over the type of term, we should also use the parametrized version of Sort for Type' (the parametrized version of Type). I'll try out if this can be made to work.

@jespercockx

Copy link
Copy Markdown
Member

I managed to fix the problem in the end, but I think all the extra 'coerce's in Substitute really make the code a lot harder to understand or edit. I'd really prefer if there was a solution that doesn't touch the basic substitution logic (like just instantiating on-the-fly during printing like I suggested, I still don't understand why that doesn't work).

@Saizan

Saizan commented Jul 9, 2019

Copy link
Copy Markdown
Collaborator Author

@jespercockx If we also parametrize Dom then the types align better: ce155e8

The Coercible stuff is so we can write a single function for both Term and BraveTerm but do the right thing in the recursive calls to applySubst and applyE (even when they are nested under some other type constructor).

(like just instantiating on-the-fly during printing like I suggested, I still don't understand why that doesn't work)

The main thing is that it seems we still want to get Internal syntax out of instantiating blocking metas, so that we can do it for [Constraint] and run mentionsMeta on the result. Also meta solutions come fully-abstracted so we would want to perform at least the substitution that comes from reducing those lambdas, otherwise we'd get quite unreadable terms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants