Yes it does, thank you for the comprehensive answer. I think, it would be useful if you added your reply to library repo.
I only have an experience with a result library. Therefore I can’t speak to the rest libs of the list which you’ve mentioned.
Result only accepts exactly the format {:ok, value}/{:error, problem}
That’s right. You can catch situations where we have :ok/:error
by pattern matching. For example:
def do_something(:ok) do
Result.ok("result is ok")
end
def do_something(_) do
Result.error("result is error")
end
And these functions you can use further in your pipes with combination Result.map, Result.and_then
, etc… For {:ok, data, metadata}
is appropriate to put data, metadata
into e.g. Map and then use Result
functions again in pipes.
Result has a bunch of monad-inspired functions, but no overloaded case
or with
statements.
Because Result
doesn’t need it. Check following examples how Result
is used for these cases. For case
: functions save and below write/close
, for with
: fold