RTypes v0.1.1 RTypes View Source

The module defines the derive/1 macro which can be used to derive a run-time checker for the given type.

The module also defines a function derive/3 which can be used at run time. However, it must be given arguments as module, type name, and a list of type args.

Usage

Using derive/1 macro

iex> require RTypes, as: RTypes
iex> is_port_number = RTypes.derive(:inet.port_number())
iex> is_port_number.(8080)
true

Note that the macro expects the argument as in module.type(arg1, arg2). That is a module name followed by . and the type name, followed by type parameters enclosed in parenthesis.

Using derive/3 function

iex> is_keyword_list = RTypes.derive(Keyword, :t, [{:type, 0, :pos_integer, []}])
iex> is_keyword_list.(key1: 4, key2: 5)
true

Link to this section Summary

Link to this section Functions

Link to this function

derive(mod, type_name, type_args) View Source