Packages

Native infix operators that uses Protocols

Current section

Files

Jump to
infix lib infix.ex
Raw

lib/infix.ex

defmodule Infix do
defmacro __using__(opts \\ []) do
arithmetic = Keyword.get(opts, :arithmetic, [
{:+, 2},
{:-, 2},
{:*, 2},
{:/, 2},
])
comparison = Keyword.get(opts, :comparison, [
{:>, 2},
{:>=, 2},
{:<=, 2},
{:==, 2},
{:===, 2},
{:!=, 2},
{:!==, 2}
])
overrides = arithmetic ++ comparison
quote do
import Kernel, except: unquote(overrides)
import Infix.Comparison, only: unquote(comparison)
import Infix.Arithmetic, only: unquote(arithmetic)
end
end
end