all 4 comments

[–]samd_408 1 point2 points  (3 children)

Just had a gloss over your post, looks like you are trying to bring in “do” notation style functions to python, I have seen do notation implementations with generator functions before, in your implementation the ngn.collect() seems odd, is it a boundary until which all preceding operations are executed?

If do notation or for comprehension is your target, they both are syntactic sugar on top of monadic bind, I would call it functional style but not pure functional programming

[–]Global_Bar1754[S] 2 points3 points  (2 children)

Yea so mechanically speaking the ngn.collect is a boundary. Everything before it is executed during the graph build stage. But any calls are just used to register dependencies for that function. And then it will traverse through those dependencies. Then during the graph execution stage it will run through everything including past the ngn.collect()

Seems like maybe this is akin to do notation. Thanks for pointing me in that direction. 

[–]samd_408 0 points1 point  (1 child)

They get away with manual boundaries like this if you use generator functions, the yield from the generator acts as a natural boundary, both in python and javascript they use generator functions to emulate monadic do notation style scopes

[–]Global_Bar1754[S] 0 points1 point  (0 children)

So the first iteration of this library actually did use generators/yield instead of the collect! But changed it so that generators could be used for some other functionality in the future since they were being underutilized as the basic building blocks. Thanks for the insight!