-
Notifications
You must be signed in to change notification settings - Fork 52
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
Construct sexp #1328
base: llama-lsp-lookahead
Are you sure you want to change the base?
Construct sexp #1328
Conversation
Remaining: finish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed the go
functions
switch (term.term) { | ||
| Invalid(string) => Atom(string) | ||
| EmptyHole => Atom("?") | ||
| MultiHole(_) => Atom("Not implemented") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be "(multihole ...)" for completion.
| Tuple(list) => List([Sexp.Atom("tuple")] @ List.map(go, list)) | ||
| Var(t) => Atom(t) | ||
| Let(pat, exp1, exp2) => | ||
List([Atom("let"), List([go(exp1), go(exp2)]), goUPat(pat)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the pattern should go first, then exp1 and then next to it (not nested) exp2
| Seq(exp1, exp2) => List([Atom("seq"), go(exp1), go(exp2)]) | ||
| Test(t) => List([Atom("test"), go(t)]) | ||
| Cons(head, tail) => List([Atom("cons"), go(head), go(tail)]) | ||
| ListConcat(list1, list2) => List([Atom("@"), go(list1), go(list2)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe concat
to be consistent with us using cons
rather than ::
and goUPat: Term.UPat.t => Sexp.t = | ||
pat => { | ||
switch (pat.term) { | ||
| EmptyHole => Atom("?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@disconcision do we want to use ?
or ??
for empty holes?
switch (pat.term) { | ||
| EmptyHole => Atom("?") | ||
| Triv => List([]) | ||
| MultiHole(_) => Atom("Not implemented") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
typ => { | ||
switch (typ.term) { | ||
| EmptyHole => Atom("EmptyHole") | ||
| MultiHole(_) => Atom("MultiHole") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
| Var(string) => Atom(string) | ||
| Constructor(string) => Atom(string) | ||
| Invalid(string) => Atom(string) | ||
| Sum(_list) => Atom("list") //List([Sexp.Atom("sum")] @ List.map(goTyp, list)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to add support for sum types (algebraic data types)
| Constructor(string) => Atom(string) | ||
| Invalid(string) => Atom(string) | ||
| Sum(_list) => Atom("list") //List([Sexp.Atom("sum")] @ List.map(goTyp, list)) | ||
| Arrow(_, _) => Atom("Arrow") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to add support for arrow types
| Invalid(string) => Atom(string) | ||
| Sum(_list) => Atom("list") //List([Sexp.Atom("sum")] @ List.map(goTyp, list)) | ||
| Arrow(_, _) => Atom("Arrow") | ||
| Parens(_) => Atom("Parens") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just recurse down as in the other parens cases
| Sum(_list) => Atom("list") //List([Sexp.Atom("sum")] @ List.map(goTyp, list)) | ||
| Arrow(_, _) => Atom("Arrow") | ||
| Parens(_) => Atom("Parens") | ||
| Ap(_, _) => Atom("Ap") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
treat the same as other ap cases
This branch seeks to add functionality to generate an sexp from valid Hazel code in the file
src/haz3lweb/SexpConversion.re
.