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

Create stuck bindings for fun and profit (type errors, postulates) #132

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

Blaisorblade
Copy link
Collaborator

@Blaisorblade
Copy link
Collaborator Author

This seems to work.
To test, I took Data/Pair1.lpts, and introduced a bug in cons1, which has a type annotation. Now users of cons1 don't get any more "Unbound identifier" errors.

./Data/Pair1.lpts:8.60-8.62: Type error: we expected two terms to be equivalent but they are not.
  The function has an unexpected codomain.
  Checked term: k a
  Actual type: B -> R
  But we expected type: R
  Difference
    actual:   B -> R
    expected: R     

  cons1 (A B : *) : A -> B -> Pair1 A B = lambda a b R k . k a;
                                                           ^^^

./Data/Pair1.lpts:13.20-13.24: Unbound identifier: cons1

  lambda f g p . cons1 B D (f (fst1 A C p)) (g (snd1 A C p));
                 ^^^^^

Automating this test depends on #94, but I could add files to examples/neg.

Then, I turned cons1 into a postulate, and the code compiled with no error. However, because of limitations of the parser support, I needed to desugar by hand the telescope:

postulate cons1 : Pi (A B : *). A -> B -> Pair1 A B;

However, the limitation is trivial to fix, since postulates reuse the code for bindings (and just omit the body).

Untested. This is a close variant to Tillmann's proposal in Toxaris#98.
Tillmann suggested writing `recover` in terms of `recoverWith`, but that
requires changing more code, and it was not fully obvious to me how to do those
changes.
Follow more closely Tillmann's pseudocode. Instead of generating a typed
variable by hand (duplicating typechecker logic/using a not fully
documented API), and then get from it a value (by evaluation), a type
and a sort, just generate an untyped value by hand (which is easier),
and pass the expected type/sort separately.

I'll admit these conditionals in the needed code are slightly more
complex, but I guess they're OK.

Also, the variable names in the new code are not single letters, which
is somewhat inconsistent (but then, I don't get the old names anyway).
Declarations without type annotations are going to be well-sorted
in *some* PTS, which might be bigger than the one considered. Hence call
checkProperType there anyway. This finally achieves the consistency
discussed in Toxaris#98.
This is just (the semantics of) Proposal 1 (with a twist), based on the
code for Bind.

No test added yet.
That's convenient when refactoring a binding to a postulate, and since
postulates reuse code for bindings, it's also trivial to support.

For instance, now we can turn:

> cons1 (A B : *) : A -> B -> Pair1 A B = ...;

into:

> postulate cons1 (A B : *) : A -> B -> Pair1 A B;
Add filepath explicitly for the tests as well (even though elsewhere
it's implied by the pts library).
Files are shown in testing output only if they contain assertions (which
seems unfortunate), so add some now.
@Blaisorblade
Copy link
Collaborator Author

Just rebased on top of master (also to fix merge conflicts).

@Blaisorblade Blaisorblade assigned Toxaris and unassigned Blaisorblade Feb 8, 2015
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.

If a definition fails, all users trigger errors Support postulates.
2 participants