Fix that the bindings of a `Let` are not shared within each other
Consider the following Program:
test = let x = const (1 ? 2) y
y = x
in x + y
Where should we put the call to 'share'? This is non-trivial. Maybe something like a monadic fixpoint operator would help, but how would that be implemented for Nondeterminism, or any effect in general? There are also some problems with the semantics of recursive let bindings and call-time-choice as documented (for example) here: curry/kics2#21.
The best we could currently do is to share variables only in non-recursive situations. E.g. the following can be transformed correctly, mainly because the let-expression could be split into two nested let bindings.
test = let x = 1 ? 2
y = x
in x + y
Edited by Kai Prott