News for hackers. Stuff that matters.
Re:Mental models around Ok-Wrapping by klodolph on Friday April 10, 2020 @11:28AM (#22834008)
Result doesn’t break from the monadic mold.
Re:Mental models around Ok-Wrapping by efnx on Friday April 10, 2020 @11:37AM (#22834111)
It does in that it has two type variables. In Haskell Either is not a monad - (Either a) is.
Re:Mental models around Ok-Wrapping by bcheung on Friday April 10, 2020 @01:48PM (#22835390)
The 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.

Re:Mental models around Ok-Wrapping by efnx on Sunday April 12, 2020 @12:52AM (#22846137)
You’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.
Re:Mental models around Ok-Wrapping by lmm on Friday April 10, 2020 @08:43PM (#22838803)
For 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.