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

Integrate menhir parser and elaborator tests #1220

Draft
wants to merge 38 commits into
base: dev
Choose a base branch
from
Draft

Conversation

7h3kk1d
Copy link
Contributor

@7h3kk1d 7h3kk1d commented Feb 25, 2024

No description provided.

@cyrus-
Copy link
Member

cyrus- commented Feb 27, 2024

@green726 are you taking a look at this PR or what is the plan? @7h3kk1d

@7h3kk1d
Copy link
Contributor Author

7h3kk1d commented Feb 27, 2024

@green726 are you taking a look at this PR or what is the plan? @7h3kk1d

This was still in dev from my perspective but @green726 is going to take over it from now and let me know if they need assistance.

@cyrus- cyrus- added needs-polish for PRs that are substantially complete but need final polish needs-merge for PRs that need a merge from dev labels Mar 1, 2024
@cyrus- cyrus- changed the base branch from menhir_parser to dev March 1, 2024 05:23
@cyrus- cyrus- mentioned this pull request Mar 1, 2024
@cyrus- cyrus- removed the needs-merge for PRs that need a merge from dev label Mar 14, 2024
@green726 green726 self-assigned this Apr 22, 2024
@green726 green726 marked this pull request as ready for review April 22, 2024 23:14
@green726 green726 requested a review from cyrus- April 22, 2024 23:14
@green726 green726 removed the needs-polish for PRs that are substantially complete but need final polish label Apr 23, 2024
Copy link
Member

@cyrus- cyrus- left a comment

Choose a reason for hiding this comment

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

left some notes on tweaks. this is going to need to be reworked a bit (but should be mostly similar) with @Negabinary 's upcoming refactoring of DHExp / UExp. since that is coming soon, so will hold off on merging for now but you can make the syntactic changes in the grammar in anticipation of that at least

@@ -2,7 +2,7 @@

(library
(name haz3lcore)
(libraries util re sexplib unionFind uuidm)
(libraries util re sexplib unionFind uuidm hazel_menhir)
Copy link
Member

Choose a reason for hiding this comment

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

the directory is called menhir-parser and the library is called hazel_menhir.

it may make more sense here to just put the parser in haz3lcore under a parser directory.

Copy link
Member

Choose a reason for hiding this comment

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

@cyrus- it seems that the standard/recommended way to do this is with a separate directory/library (see https://stackoverflow.com/questions/70805926/include-mly-files-nested-in-subdirectories-when-compiling-with-dune and ocaml/dune#4381) due to a bug in Dune - if you would prefer I could also place it in a subdirectory of haz3lcore with its own Dune file. I don't have a preference either way - what would you prefer? Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Can we put the necessary dune menhir invocations into the haz3lcore dune file or does it need its own in a subdirectory? No strong preference here, but would like the directory and library to at least have the same name.

Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately it seems that we can't (that's a known bug with dune according to the stack overflow I linked) - we can put the parser in haz3lcore but the parser directory will also need its own dune file. I think that will keep it part of the same library as haz3lcore? I could try that and if that doesn't work I'll just change the current directory/library to have matching names?

Copy link
Member

Choose a reason for hiding this comment

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

sounds good

| Let(DHPat.t, t, t)
| FixF(Var.t, Typ.t, t)
| Fun(DHPat.t, Typ.t, t, option(Var.t))
| Filter(DHFilter.t, t) //pause a == 2 b
Copy link
Member

Choose a reason for hiding this comment

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

this can have a few different concrete forms depending on the filter... @tonyfettes

| EmptyHole(MetaVar.t, HoleInstanceId.t)
| NonEmptyHole(ErrStatus.HoleReason.t, MetaVar.t, HoleInstanceId.t, t)
| FreeVar(MetaVar.t, HoleInstanceId.t, Var.t)
| EmptyHole(MetaVar.t, HoleInstanceId.t) //()
Copy link
Member

Choose a reason for hiding this comment

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

() is the notation for unit values, so let's use ? for empty holes

| NonEmptyHole(ErrStatus.HoleReason.t, MetaVar.t, HoleInstanceId.t, t)
| FreeVar(MetaVar.t, HoleInstanceId.t, Var.t)
| EmptyHole(MetaVar.t, HoleInstanceId.t) //()
| NonEmptyHole(ErrStatus.HoleReason.t, MetaVar.t, HoleInstanceId.t, t) //(_HOLE x)
Copy link
Member

Choose a reason for hiding this comment

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

let's use {{e}} for non-empty holes

| FreeVar(MetaVar.t, HoleInstanceId.t, Var.t)
| EmptyHole(MetaVar.t, HoleInstanceId.t) //()
| NonEmptyHole(ErrStatus.HoleReason.t, MetaVar.t, HoleInstanceId.t, t) //(_HOLE x)
| FreeVar(MetaVar.t, HoleInstanceId.t, Var.t) //(_FREE x)
Copy link
Member

Choose a reason for hiding this comment

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

let's use {{?x}} for free variables

| BoundVar(Var.t) //x
| Sequence(t, t) //a; b
| Let(DHPat.t, t, t) //let x = y in z
| FixF(Var.t, Typ.t, t) //_FIX f Int -> Int fun: Int x -> 1 + x f in 55
Copy link
Member

Choose a reason for hiding this comment

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

I believe the syntax here should be fix x : ty -> e

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I fixed that but I unfortunately cant use the "->" because it seems to create a conflict in Menhir between the exp and typ (I'm pretty sure it is conflicting with the "->" in arrow types) so instead I used "=>". The syntax is now fix x: ty => e, are you alright with that or would you prefer I try to find some way around the conflict?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe have it be parenthesized, so fix x -> e or fix (x : ty) -> e? would prefer to keep the Hazel notation consistent here so if we change it here then we should change it in Hazel

Copy link
Member

Choose a reason for hiding this comment

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

That worked! Thank you!

| Sequence(t, t) //a; b
| Let(DHPat.t, t, t) //let x = y in z
| FixF(Var.t, Typ.t, t) //_FIX f Int -> Int fun: Int x -> 1 + x f in 55
| Fun(DHPat.t, Typ.t, t, option(Var.t)) //fun: Int x -> x + 1
Copy link
Member

Choose a reason for hiding this comment

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

the syntax here should be fun p -> e

Copy link
Member

Choose a reason for hiding this comment

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

I had to add in manual annotations for the type of the function to be able to construct the dhexp with the type. The current elaborator gets the type from the pattern but uses the statics map - I thought it would be best to just add in the annotations rather than try to interface with that. What do you think?

| TypFun(Term.UTPat.t, t, option(Var.t))
| TypAp(t, Typ.t)
| Ap(t, t)
| Ap(t, t) //a(1)
Copy link
Member

Choose a reason for hiding this comment

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

e1(e2)

| Cons(t, t) //a :: b
| ListConcat(t, t) //a @ b
| Tuple(list(t)) //(a, b)
| Prj(t, int) //TODO
Copy link
Member

Choose a reason for hiding this comment

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

e.n

| Constructor(string) //X
| ConsistentCase(case) //4 == 3 | true => 24 | false => false end
| Cast(t, Typ.t, Typ.t) //x <Unknown Internal => Int>
| FailedCast(t, Typ.t, Typ.t) //x ?<Int => Int>
Copy link
Member

Choose a reason for hiding this comment

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

e<ty1 =!> ty2> or something like that

@cyrus- cyrus- marked this pull request as draft April 26, 2024 01:33
@green726
Copy link
Member

green726 commented Apr 26, 2024

Sounds good, thanks for the feedback. I'll make those syntactic changes and wait for the new UExp/DHExp to update then I'll mark as ready for review again.

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.

None yet

3 participants