View Source Newt behaviour (Newt v0.1.0)

A low-cost abstraction implementing the NewType pattern in Elixir

There is no way (currently) to define zero-cost NewTypes in Elixir (like you can in Rust, Haskell, F#, etc.) because Elixir is dynamically typed. However, this library provides a low-cost abstraction that allows you to define NewTypes in Elixir with minimal boilerplate.

Summary

Callbacks

@callback validate(value :: any()) :: {:ok, any()} | {:error, String.t()}

Functions

Link to this macro

newtype(type_name, typespec)

View Source (macro)
@spec newtype(atom(), term()) :: Macro.t()
Link to this macro

newtype(type_name, typespec, list)

View Source (macro)
@spec newtype(atom(), term(), [{:do, Macro.t()}]) :: Macro.t()