do
x <- [1, 2, 3]
y <- [4, 5, 6]
return (x + y)
-- [5, 6, 7, 6, 7, 8, 7, 8, 9]
Here we have a series of assignments followed by an expression computing a result. You can't tell directly, but this is using do-notation in the List monad -- an assignment `x <- [...]` picks a value from the list, then continues. In fact, this code is run once for every possible choice from the given lists, and all of the results are aggregated into a list.The earlier commenter referred to the Identity monad, which would look like:
do
x <- 3
y <- 5
return (x + y)
-- 8
No special lists this time -- what you put on the right is what gets stored in the variable on the left. This is what you're used to in any imperative language.I suspect `bb` is a little more special, because Ron mentioned it has similarities to LOOP. I'd guess it supports recursive definitions somehow, but it's not clear what the difference actually is.