Are there any interesting commutative monads in Haskell? -
until edited today, haskell wiki claimed maybe commutative monad (actually, think still claims somewhere). wrong, because
do {a <- nothing; b <- undefined; homecoming (a,b)} === nil while
do {b <- undefined; <- nothing; homecoming (a,b)} === undefined this failure of commutativity rather of import in real code: programmers rely on fact computation stop reaches nothing.
this leaves (among monads described commutative on haskell wiki) reader monad, doesn't seem terribly exciting. raised question in mind whether there commutative monads in haskell substantially different reader, aside restrictions of reader.
i realized it's possible create restricted writer monad commutative—it needs accumulate values in commutative monoid. still not interesting.
statements have implied "ignoring bottoms" requirement , 1 of cases. it's commutative if ignore bottoms. it's improve explicitly express requirement though, because can become important.
if do ignore bottoms, maybe commutative monad well. of course, mentioned in question, bottoms of import consider practically speaking, aware of non-commutativity in presence.
haskell monads
No comments:
Post a Comment