-
Notifications
You must be signed in to change notification settings - Fork 5
Desugarings
Jan Christopher Vogt edited this page Feb 2, 2016
·
2 revisions
If with awaits in condition (split into multi-level if):
val x: List[Int] = Nil
sequence[List] {
if (~x == 0) { ifTrue }
else { ifFalse }
}
becomes
val x: List[Int] = Nil
sequence[List] {
val $fresh = ~x
if ($fresh == 0) { ifTrue }
else { ifFalse }
}
val x: List[Int] = Nil
val y: List[Int] = Nil
sequence[List] {
if (~x == 0 && ~y > 10) { ifTrue }
else { ifFalse }
}
becomes
val x: List[Int] = Nil
val y: List[Int] = Nil
sequence[List] {
val $fresh1 = ~x
if ($fresh1 == 0) {
val $fresh2 = ~y
if ($fresh2 > 10) ifTrue
else ifFalse
} else ifFalse
val x: List[Int] = Nil
val y: List[Int] = Nil
sequence[List] {
if (~x == 0 || ~y > 10) { ifTrue }
else { ifFalse }
}
becomes
val x: List[Int] = Nil
val y: List[Int] = Nil
sequence[List] {
val $fresh1 = ~x
if ($fresh1 == 0) ifTrue
else {
val $fresh2 = ~y
if ($fresh2 > 10) ifTrue
else ifFalse
}
If with awaits in body (wrap each part of the body in another sequence
and
await the result):
val x: List[Int] = Nil
sequence[List] {
if (true) { ~x }
else { 3 }
}
becomes
val x: List[Int] = Nil
sequence[List] {
val $fresh = (
if (true) sequence[List] { ~x }
else sequence[List] { 3 }
)
~($fresh)
}