3 ms·
It does in that it has two type variables. In Haskell Either is not a monad - (Either a) is.
by efnx 7y ago
It does in that it has two type variables. In Haskell Either is not a monad - (Either a) is.
- bcheung 7y agoThe number of variables doesn't matter, as long as they are the same type is the part that matters. <T, E> can be thought of as a pair, tuple, cartesian product. Likewise you can expand it to as many values as you want. If type C is just (T, E) then it is really just Result<C> at that point. The first T can vary but as long as everything after that is fixed to the same type, you can have as many variables/types as you want and it will still be monadic.
- efnx 7y agoYou’re reducing two type variables down to one. The number of type variables matter. The kind of the type matters. Look at the definition of Monad for Either. You’ll see.
- lmm 7y agoFor any E, Result<E, ?> forms a valid monad. So yes technically Result is a family of monads rather than a single monad, just as technically the monad is not the type itself but the combination of the type and two functions defined on that type, but that's irrelevant pedantry most of the time.