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

Compile where clauses #23

Merged
merged 4 commits into from
Nov 16, 2020
Merged

Compile where clauses #23

merged 4 commits into from
Nov 16, 2020

Conversation

omelkonian
Copy link
Contributor

  • also compiling postulates to undefined

@omelkonian omelkonian force-pushed the where-clause branch 2 times, most recently from c1f7edf to 0d2e250 Compare November 8, 2020 21:57
Copy link
Member

@UlfNorell UlfNorell left a comment

Choose a reason for hiding this comment

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

If you try to add an argument to ex and use it in one of the where functions it fails. I don't think it's worth doing this if it only works for definitions without left-hand sides.

Also, do you have a use case in mind for compiling postulates to undefined? I can't think of situation where you would actually want this...

@omelkonian
Copy link
Contributor Author

omelkonian commented Nov 9, 2020

If you try to add an argument to ex and use it in one of the where functions it fails. I don't think it's worth doing this if it only works for definitions without left-hand sides.

I see, the problem is that the definitions inside where are 'lifted' and thus require the arguments to ex as input again.
Would it be possible to (partially) apply all of these definitions and then compile?
Or is this approach doomed to fail from your experience?

Also, do you have a use case in mind for compiling postulates to undefined? I can't think of situation where you would actually want this...

Re. postulates, you will never want it in the end result, but it seems useful while prototyping: think of postulate a : A as a shorthand for:

a :: A
a = undefined

(another way to do it is add a postulate in Prelude.undefined and use a full declaration)

@UlfNorell
Copy link
Member

Would it be possible to (partially) apply all of these definitions and then compile? Or is this approach doomed to fail from your experience?

This should be possible. There's an Apply instance for Definition so hopefully you can grab the lhs variables of the clauseTel and simply apply them before compiling the where-functions.

@UlfNorell
Copy link
Member

another way to do it is add a postulate in Prelude.undefined and use a full declaration

Hm.. since the objective is to prove things about the code, I'd rather not add undefined to the Prelude. Maybe it could be error "postulate: a" rather than undefined though.

@omelkonian omelkonian force-pushed the where-clause branch 3 times, most recently from c5203c8 to e9694fc Compare November 9, 2020 22:45
@omelkonian omelkonian requested a review from UlfNorell November 10, 2020 00:18
Copy link
Member

@UlfNorell UlfNorell left a comment

Choose a reason for hiding this comment

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

Progress! Still doesn't quite work for functions with multiple clauses.

Main.hs Outdated Show resolved Hide resolved
Main.hs Outdated Show resolved Hide resolved
test/Where.agda Show resolved Hide resolved
@omelkonian omelkonian force-pushed the where-clause branch 2 times, most recently from a0f2b2f to ec44f1b Compare November 12, 2020 11:55
omelkonian and others added 2 commits November 12, 2020 14:02
  * also compiling postulates to undefined
If nothing else this makes it easier to debug failures when we try to translate
generated types.
Copy link
Member

@UlfNorell UlfNorell left a comment

Choose a reason for hiding this comment

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

We're getting there! Some cosmetics and a problem with finding local declarations.

Main.hs Outdated Show resolved Hide resolved
Main.hs Outdated Show resolved Hide resolved
Main.hs Outdated Show resolved Hide resolved
Main.hs Outdated Show resolved Hide resolved
@omelkonian omelkonian requested a review from UlfNorell November 12, 2020 16:59
Copy link
Member

@UlfNorell UlfNorell left a comment

Choose a reason for hiding this comment

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

Good job!

@UlfNorell UlfNorell merged commit 8b902ab into master Nov 16, 2020
@UlfNorell UlfNorell deleted the where-clause branch November 16, 2020 07:15
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.

2 participants