-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checked algebraic laws, refactoring #37
Conversation
@@ -60,8 +60,7 @@ defmodule Noether.Either do | |||
{:error, "Value not found"} | |||
""" | |||
@spec join(either()) :: either() | |||
def join({:ok, {:ok, a}}), do: {:ok, a} | |||
def join({:ok, {:error, a}}), do: {:error, a} | |||
def join(a = {_, {_, _}}), do: bind(a, & &1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Haskell, join
from Control.Monad
is implemented in terms of bind
.
@@ -9,10 +9,10 @@ defmodule Noether.Maybe do | |||
|
|||
## Examples | |||
|
|||
iex> map(nil, &Kernel.abs/1) | |||
iex> Noether.Maybe.map(nil, &Kernel.abs/1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The library that we use for Property Testing has a function called map
, therefore I need to break the ambiguity.
@@ -35,9 +35,9 @@ defmodule Noether.MixProject do | |||
# Run "mix help deps" to learn about dependencies. | |||
defp deps do | |||
[ | |||
{:credo, "~> 1.6.4", only: :dev, runtime: false}, | |||
{:credo, "~> 1.7", only: :dev, runtime: false}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a long due version bump
ff37bcf
to
d5d9c36
Compare
d5d9c36
to
a5af09e
Compare
After a conversation with Tom, I wanted to check that Noether respects basic Functor and Monadic laws. The good news is that it does, the bad news is that
Either.bind
should ideally be more strict.For now I decided to go with a warning in the docs instead of a proper error.
After writing the tests, I decided to increase the inter-function dependency in
Maybe
. I doubt this will cause any issue in existing codebases, therefore I only consider this a "refactoring change" in the semver.