-
Notifications
You must be signed in to change notification settings - Fork 28
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
Support the use of do
as a connective in UCS
#246
Conversation
Nice change! There are a few places to update that currently use |
Co-authored-by: Lionel Parreaux <[email protected]>
Can you please squash this PR when you merge? |
8b4b6a5
to
747a099
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.
All right, let's merge this.
Though I am not quite sure about the do
situation. I don't like that it's currently overloaded, making things a bit difficult to parse sometimes, as in:
while
do log(i)
i < 3 do set i += 1
or
while
do print(ls)
ls is Cons(h, tl) do set ls = tl
Here the two uses of do
serve quite different purposes, making things read a bit awkward.
Main features:
do
can appear in place ofthen
, and the default value of its UCS expression will be replaced withUnitLit
.do
can appear in a split of UCS to introduce expressions whose results are not needed between branches.Relevant changes:
do
has the same left and right precedence asthen
and can be parsed as an infix operator.Set
s toDesugarer
tracking the usage ofdo
andthen
. If they are all used in the same UCS expression, an error will be reported.ucs/syntax/Do.mls
, which shows the semantic difference betweendo
andthen
.Not so relevant changes:
apply
toDesugarer
. It should be called no matter we want to desugarcase
,if
, or UCS shorthands.kwLoc: Opt[Loc]
field toIfLike
andCase
for better error reporting.