make generator monadic