Unit Fun v0.5.3 API Reference

Modules

Adds units to numbers in elixir to give some added type saftey when dealing with numeric quantities

[Experimental] Provides macros to create a domain specific language around units

Useing this macro replaces the kernel maths functions with unit aware ones

Useed by a module to generate the definition of a unit. For example the following code would define Pence:

defmodule Pence do
  use UnitFun.Unit
end

Unitfun uses modules to represent units. All units must implement this behaviour

Provides functions for applying units on top of bare values. Normally imported

import UnitFun.UnitTypes
ten_pence = 10 |> with_units(Pence)
# or
twenty_pence = 20 <~ Pence

Provides a struct that represents a value with units

Exceptions

Protocols

Implementing this protocol definines a relationship into units. An example of this should be Pence and Pounds

Implementing this protocol allows custom additon / subtraction to occur

Implementing this protocol allows custom division

Implementing this protocol allows custom multiplication