Anyway, the F# code, IIUC, lets you do exactly what you want it to do, although you'd have to replace the ifs with guards.
[0]: https://rosettacode.org/wiki/Amb#Monadic