Skip to content

Instantly share code, notes, and snippets.

@houmanka
Created April 1, 2020 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save houmanka/0705ccf51c59a7a90971a63914f66546 to your computer and use it in GitHub Desktop.
Save houmanka/0705ccf51c59a7a90971a63914f66546 to your computer and use it in GitHub Desktop.
Changed all are in the actual project
def decrement(%Monad.Result{type: :ok} = state) do
state.value
|> decrement
end
def increment(
%Monad.Result{type: :ok} = first,
%Monad.Result{type: :ok} = second ) do
second = second.value |> Enum.count
increment(first.value, second)
end
def combine(
%Monad.Result{type: :ok} = first,
%Monad.Result{type: :ok} = second ) do
combine(first.value, second.value)
end
def filter(%Monad.Result{type: :ok} = list), do: list.value |> filter()
def sum_of(%Monad.Result{type: :ok} = list), do: list.value |> sum_of
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment