Unit Fun v0.7.0 API Reference

Modules

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

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

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

Implementing this protocol allows custom additon / subtraction to occur

Implementing this protocol allows custom division

Implementing this protocol allows custom multiplication

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

Valudites if a UnitFun.Value is a legal. All units provide a function called facts() that returns a list of functions

Provides a struct that represents a value with units

Exceptions