(reorganize m)
Reorganize the monadic computation m so that binds nested on the left are moved to the right, i.e. transform expressions like
(>>= (>>= (>>= m f) g) h)
into expressions like
(>>= m (fn [x] (>>= (f x) (fn [y] (>>= (g y) h))))).
A monad implementation for which these two expressions give different results is broken.
Similarly reorganizes mplus operations nested on the left:
(mplus (mplus (mplus a b) c) d)
Becomes
(mplus a (mplus b (mplus c d))).
And, similarly, an mplus operation which is not associative is considered to be in error.
Both transformations are interleaved:
(mplus (mplus (>>= (>>= (mplus (mplus a b) c) f) g) d) e)
becomes
(mplus (>>= (mplus a (mplus b c)) (fn [x] (>>= (f x) g))) (mplus d e)).
Note that only mplus and bind operations are investigated: the reorganization does not recurse into the monadic-computation arguments of e.g. listen, local, or pass.
Reorganize the monadic computation m so that binds nested on the left are moved to the right, i.e. transform expressions like (>>= (>>= (>>= m f) g) h) into expressions like (>>= m (fn [x] (>>= (f x) (fn [y] (>>= (g y) h))))). A monad implementation for which these two expressions give different results is broken. Similarly reorganizes mplus operations nested on the left: (mplus (mplus (mplus a b) c) d) Becomes (mplus a (mplus b (mplus c d))). And, similarly, an mplus operation which is not associative is considered to be in error. Both transformations are interleaved: (mplus (mplus (>>= (>>= (mplus (mplus a b) c) f) g) d) e) becomes (mplus (>>= (mplus a (mplus b c)) (fn [x] (>>= (f x) g))) (mplus d e)). Note that *only* mplus and bind operations are investigated: the reorganization does not recurse into the monadic-computation arguments of e.g. listen, local, or pass.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close