-
Notifications
You must be signed in to change notification settings - Fork 0
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
Lift lambdas #44
Lift lambdas #44
Conversation
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.
Thanks Hans! This is great start. Wrote some style suggestions (:
27b463c
to
a6ae22a
Compare
@XijiaoLi I ran into a very interesting issue while I was trying to make my code pass the regression tests. Consider
While the type annotation says Is the behavior I encountered expected? Does your type inference unify(?) |
It should be |
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.
Thanks @hmontero1205 ! This is awesome work.
This looks good overall. I left a bunch of suggestions inline, mostly places where you could have used existing helpers.
I'm requesting changes because this is still missing Haddock comments, and a test suite demonstrating correctness. For the test suite, add a new test suite named ir-to-ir where we can write tests that assert the correctness of source-to-source transformations.
@XijiaoLi I'm confused then -- does your type inference logic compare I'm still not sure which type annotation I should be following when I am reconstructing lambdas -- the type annotation on the lambda itself or the type annotation on the lambda bodies. To reiterate, I was doing the latter but I'm not sure if I am supposed to be doing the former or if it really shouldn't matter to this compiler pass? @j-hui any thoughts? |
`par` should return a tuple of all its expressions.
I'm still not sure which type annotation I should be following when I am
reconstructing lambdas -- the type annotation on the lambda itself or the
type annotation on the lambda bodies
The two should be more or less equivalent; I think the difference you're
seeing is not intentional. I think it's easier to use the type annotation
on the overall lambda.
…On Fri, Nov 26, 2021 at 1:40 PM Hans Montero ***@***.***> wrote:
It should be ((), ()). I think it was a mistake that was made in the
first version of doubleblink.ssl and we just haven't changed it. My type
inference should infer the type of par as Tuple [t] Builtin type (e.g., ((),
()) in this case). However, I believe that the current Codegen does not
support Tuple type yet based on Codegen.hs#L164
<https://github.com/ssm-lang/sslang/blob/main/src/Codegen/Codegen.hs#L164>
.
@XijiaoLi <https://github.com/XijiaoLi> I'm confused then -- does your
type inference logic compare main's annotated return type of () to ((),
())?
I'm still not sure which type annotation I should be following when I am
reconstructing lambdas -- the type annotation on the lambda itself or the
type annotation on the lambda bodies. To reiterate, I was doing the latter
but I'm not sure if I am supposed to be doing the former or if it really
shouldn't matter to this compiler pass? @j-hui <https://github.com/j-hui>
any thoughts?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#44 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AC2A5DDRXMWMT2BMQEYGUGTUN7ICFANCNFSM5IA3ILPQ>
.
|
I mean, the current type annotation for |
@XijiaoLi could you issue a PR to fix that? Happy to stamp it.
…On Fri, Nov 26, 2021 at 1:47 PM Xijiao ***@***.***> wrote:
@XijiaoLi <https://github.com/XijiaoLi> I'm confused then -- does your
type inference logic compare main's annotated return type of () to ((),
())?
I'm still not sure which type annotation I should be following when I am
reconstructing lambdas -- the type annotation on the lambda itself or the
type annotation on the lambda bodies. To reiterate, I was doing the latter
but I'm not sure if I am supposed to be doing the former or if it really
shouldn't matter to this compiler pass? @j-hui <https://github.com/j-hui>
any thoughts?
I mean, the current type annotation for main's return type is wrong - it
should be ((), ()) since the type of par should be a tuple. The type
annotation on the lambda bodies should always be the same as the type
annotation on the lambda's return type. We should really fix this
regression test.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#44 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AC2A5DGTRQM34P3BX5OGKGTUN7I3PANCNFSM5IA3ILPQ>
.
|
…tments for named lambdas
3b964e9
to
f1e8651
Compare
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.
@j-hui check this out, now with tests and documentation 😳
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.
LGTM overall! I'm going to stamp this for now, but there still are a few things to follow up on, for which I left comments inline.
Also, could we add a more deeply nested example? Something like:
f x y =
let z = 4
let g a =
let h b = a + b + x
h z
g y
Opening a draft to get some feedback in. Need advice on how to type lifted lambdas and general monadic programming critiques :)
Closes #32