Good news everyone! :-)
Nimfp (https://github.com/vegansk/nimfp) now includes do notation inspired by haskell. For use it with your own types, you need to:
The types from the library (Option, List, Either, Stream) already support this contract.
Example:
proc flatMap[T](s: seq[T], f: T -> seq[T]): seq[T] =
result = newSeq[T]()
for v in s:
result.add(f(v))
template elemType(s: seq): typedesc =
type(s[0])
let res = act do:
x <- @[1, 2, 3]
y <- @[100, 200, 300]
z <- @[5, 7]
@[x * y + z]
echo res
outputs:
@[105, 107, 205, 207, 305, 307, 205, 207, 405, 407, 605, 607, 305, 307, 605, 607, 905, 907]