I’m going through the v3 tutorial, currently looking at the e/amb section. I have a question — not sure if it’s interesting or just revealing a lack of understanding on my part…
There’s this example…
(e/as-vec
(let [x (e/amb 1 2 3)]
(if (odd? x)
x
(e/amb))))
=> [1 2 3 1 2 3]
…and an explanation that mentions that Electric if’s current implementation interacts badly with product semantics
That got me thinking, and I tried this:
(e/as-vec
(let [x (e/amb 1 2 3)]
[x x]))
=> [[1 1] [1 2] [1 3] [2 1] [2 2] [2 3] [3 1] [3 2] [3 3]]
I might have expected [[1 1] [2 2] [3 3]] for the [x x] example, expecting the two xs to be the same in each case.
Would that make sense?
Wouldn’t “unifying” the two xs make the if example behave more intuitively?
Would it break something else?I agree that unifying could make sense, we're still debating it internally
Verse's if performs similar scope narrowing
OK; thanks. Interesting