Run this notebook

Use Livebook to open this notebook and explore new ideas.

It is easy to get started, on your machine or the cloud.

Click below to open and run it in your Livebook at .

(or change your Livebook location)

# Funx.Eq ```elixir Mix.install([ {:funx, "0.3.0"} ]) ``` The `Funx.Eq` protocol defines an equality function, `eq?/2`, for comparing two values, and its complement, `not_eq?/2`, for checking inequality. Types that implement this protocol can define custom equality logic, allowing for domain-specific comparisons. ## Fallback The protocol uses `@fallback_to_any true`, meaning that if a specific type does not implement `Funx.Eq`, it falls back to the default implementation for `Any`, which uses Elixir's built-in equality operator (`==`). ## Examples ```elixir import Funx.Eq ``` With a custom implementation for a `Funx.Monad.Maybe` type: ```elixir eq?(Funx.Monad.Maybe.just(3), Funx.Monad.Maybe.just(3)) ``` ```elixir eq?(Funx.Monad.Maybe.just(3), Funx.Monad.Maybe.just(5)) ``` ```elixir eq?(Funx.Monad.Maybe.nothing(), Funx.Monad.Maybe.nothing()) ``` ```elixir eq?(Funx.Monad.Maybe.nothing(), Funx.Monad.Maybe.just(5)) ``` Checking inequality with `not_eq?/2`: ```elixir not_eq?(Funx.Monad.Maybe.just(3), Funx.Monad.Maybe.just(3)) ``` ```elixir not_eq?(Funx.Monad.Maybe.just(3), Funx.Monad.Maybe.just(5)) ``` ```elixir not_eq?(Funx.Monad.Maybe.nothing(), Funx.Monad.Maybe.nothing()) ``` ```elixir not_eq?(Funx.Monad.Maybe.nothing(), Funx.Monad.Maybe.just(5)) ``` ## eq?/2 Returns `true` if `a` is equal to `b`, otherwise returns `false`. ### Examples ```elixir eq?(1, 1) ``` ```elixir eq?(1, 2) ``` ## not_eq?/2 Returns `true` if `a` is not equal to `b`, otherwise returns `false`. ### Examples ```elixir not_eq?(1, 1) ``` ```elixir not_eq?(1, 2) ```
See source

Have you already installed Livebook?

If you already installed Livebook, you can configure the default Livebook location where you want to open notebooks.
Livebook up Checking status We can't reach this Livebook (but we saved your preference anyway)
Run notebook

Not yet? Install Livebook in just a minute

Livebook is open source, free, and ready to run anywhere.

Run on your machine

with Livebook Desktop

Run in the cloud

on select platforms

To run on Linux, Docker, embedded devices, or Elixir’s Mix, check our README.

PLATINUM SPONSORS
SPONSORS
Code navigation with go to definition of modules and functions Read More