-
Yes, or with
with
if you want an else, but you’ll want to make the tagged typed beok: value
anderror: reason
(which is closer to a result type, but it’s a limitation of elixir tuple lists in that they are always tuples). Traditionally{:ok, value}
and:error
is the “option” type in Elixir, where{:ok, value}
and{:error, reason}
is the “result” type in Elixir. -
Oh yes, quite a lot, I’m personally a fan of expede’s libraries if you want the full haskell/scala like interfaces. There is also another library made by the same author (not at that link) that is more simple and just works with the usual elixir/erlang forms as well.
1 Like