Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/noether/either.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule Noether.Either do
@type either :: {:ok, any()} | {:error, any()}
@type fun0 :: (-> any())
@type fun1 :: (any() -> any())
@type fune :: (any() -> either())

@doc """
Given an `{:ok, value}` and a function, it applies the function on the `value` returning `{:ok, f.(value)}`.
Expand Down Expand Up @@ -96,7 +97,7 @@ defmodule Noether.Either do
iex> bind({:error, 1}, fn _ -> {:ok, 45} end)
{:error, 1}
"""
@spec bind(either(), fun1()) :: either()
@spec bind(either(), fune()) :: either()
def bind({:ok, a}, f) when is_function(f, 1), do: f.(a)
def bind(a = {:error, _}, _), do: a

Expand All @@ -114,7 +115,7 @@ defmodule Noether.Either do
iex> flat_map({:error, 1}, fn _ -> {:ok, 45} end)
{:error, 1}
"""
@spec flat_map(either(), fun1()) :: either()
@spec flat_map(either(), fune()) :: either()
defdelegate flat_map(either, f), to: __MODULE__, as: :bind

@doc """
Expand Down
1 change: 0 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ defmodule Noether.MixProject do
elixir: "~> 1.13",
start_permanent: Mix.env() == :prod,
aliases: aliases(),
dialyzer: [plt_add_deps: :transitive],
deps: deps(),
package: package(),
description: "Algebra utilities for Elixir",
Expand Down
Loading