You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It’s not possible for arbitrary monad to have inverse function of ‘sequence’ since there is no deterministic(or even possible) way to decompose given monadic value with single effect into monadic value with serveral, chained effects. Just as it’s not possible to know what values were used to calculate given value that forms monoid. (1 + 9 is 10, but 2 + 8 and 3 + 7 is also 10, it’s not possible to naturally determine combination to be used as result of inverse function)
PS. Even for Option monad, it’s still not possible to implement inverse function of sequence.
sequenceO(none, some(1)) is none, but sequenceO(none, none) is none too.
The operation
A.sequenceT
allows to convert a sequence of typed Monads into a Monad of a typed tuple, such as in thisOption
example:what is the best representation of the inverse operation?
The best I could do as a special case for
Option
was:but I wonder if there exists a concept (and more generic implementation) for this.
The text was updated successfully, but these errors were encountered: