eliom
eliom copied to clipboard
Issues with nested [%shared ...] expressions
I'm told nested expressions are meant to work, but ran into these:
let borken_maybe (x : int) s =
S.map [%shared S.map [%shared ((+) ~%x)]] s
File "bug1.eliom", line 22, characters 54-55:
Error: Unbound value x
same with
let borken_maybe (x : int) s =
S.map [%shared let x = ~%x in S.map [%shared ((+) ~%x)]] s
Furthermore, it seems nested [%shared] expressions are disallowed altogether:
let borken_maybe (x : int) s =
S.map [%shared S.map [%shared ((+) 1)]] s
File "bug1.eliom", line 22, characters 38-55:
The syntax [%shared ...] can not be nested.
Both can be worked around by moving the inner expressions to a top-level binding, but it quickly becomes quite inconvenient when you're working with dynamism (signals of signals): imagine having to use a (named) top-level function to replace every lambda :-)
As it turns out, there's a better, much more convenient workaround:
let borken_maybe (x : int) s =
let plus_x x = [%shared ((+) ~%x)] in
S.map [%shared S.map (~%plus_x ~%x) ] s