Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
41 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defmodule Versioce.Hooks do | ||
@moduledoc false | ||
|
||
@spec run(any, [module()]) :: Versioce.OK.ok_tuple() | ||
def run(params, []), do: Versioce.OK.unit(params) | ||
|
||
def run(params, [h | tail]) do | ||
params | ||
|> Versioce.OK.unit() | ||
|> Versioce.OK.bind(&h.run/1) | ||
|> run(tail) | ||
end | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
defmodule Versioce.OK do | ||
@moduledoc false | ||
|
||
@type ok_tuple :: {:ok, any} | {:error, any} | ||
|
||
@spec bind(ok_tuple, fun) :: ok_tuple() | ||
def bind({:ok, value}, func), do: func.(value) | ||
def bind({:error, reason}, _), do: {:error, reason} | ||
|
||
@spec unit(any) :: ok_tuple() | ||
def unit({:ok, _} = value), do: value | ||
def unit({:error, _} = value), do: value | ||
def unit(value), do: {:ok, value} | ||
end |