These are chat archives for evhub/coconut
Right(value), the wrapped function doesn't really need to know about anything other than
return fn(val)in your example).
skip_error_pathdoes look very similar to bind to me. Enough to make me wonder what a bind function in Coconut might look like.
data Left(error_msg): def __fmap__(self, _) = self def __join__(self) = self data Right(result): def __join__(Right(Right(x))) = Right(x) @addpattern(__join__) def __join__(Right(Left(x))) = Left(x) Either = (Left, Right) def join(x) = x.__join__() def bind(f, x) = join..fmap(f, x)
safe_halve(4) |> fmap$(sqrt) |> handle safe_halve(5) |> fmap$(sqrt) |> handle # and a contrived `bind` example... Right(5) |> bind$(safe_halve) |> fmap$(sqrt) |> handle