View Source Newt behaviour (Newt v8.2.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

Functions

A guard ensuring that an argument is of the given Newt type

Callbacks

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

Functions

Link to this macro

type!(argument, type)

View Source (macro)

A guard ensuring that an argument is of the given Newt type