elixir-monad icon indicating copy to clipboard operation
elixir-monad copied to clipboard

ErrorM treat everything but {:ok, value} as an error

Open patrickdet opened this issue 11 years ago • 0 comments

There are some(many) functions like Elixirs List.from_char_data

from_char_data(char_data) :: {:ok, char_list} | {:error, [], binary} | {:incomplete, [], binary}

In such a case I only really care about the success case of {:ok, char_list}. I would like to treat everything else as an error.

Would you accept a Pull Request for an ErrorMStrict or such with a bind function like

def bind(x, f)
def bind({:ok, a}, f) do
  f.(a)
end
def bind(error, _f) do
  error
end

patrickdet avatar May 07 '14 17:05 patrickdet