When we map 'let' terms into Java, we turn the individual bindings into local variables, taking care to get the order of variable definitions right, and wrapping them in a container for delayed evaluation in the case of recursive variables.
However, nested 'let' terms are currently unsupported. For example:
let a = 1
b = let x = 10
y = 20
in x + y
in a + b
This is a perfectly reasonable term in Haskell, but in order to map it into Java, we will need to flatten it first, e.g.
let a = 1
b = b_x + b_y
b_x = 10
b_y = 20
in a + b
Now we have siblings which reference each other, but this is supported so long as there are no cycles. This flattened structure can be mapped directly into Java.
When we map 'let' terms into Java, we turn the individual bindings into local variables, taking care to get the order of variable definitions right, and wrapping them in a container for delayed evaluation in the case of recursive variables.
However, nested 'let' terms are currently unsupported. For example:
This is a perfectly reasonable term in Haskell, but in order to map it into Java, we will need to flatten it first, e.g.
Now we have siblings which reference each other, but this is supported so long as there are no cycles. This flattened structure can be mapped directly into Java.