RTypes v0.2.1 RTypes.Extractor View Source

Link to this section Summary

Functions

Recursively extract and instantiate AST representation of a type.

Link to this section Types

Link to this type

type() View Source
type() :: {:type, line :: integer(), atom(), [type() | value()]}

Link to this type

unfolded_type() View Source
unfolded_type() :: {:type, line :: integer(), atom(), [type() | value()]}

Link to this type

value() View Source
value() :: {value_tag :: atom(), line :: integer(), term()}

Link to this section Functions

Link to this function

extract_type(mod, type_name, type_args) View Source
extract_type(module(), atom(), [type() | value()]) :: unfolded_type()

Recursively extract and instantiate AST representation of a type.

Arguments

  • mod - module

  • type_name - type name

  • type_args - arguments, if any, for the type. The arguments should be represented as AST, for example, {:type, 0, :list, []}

Usage

  iex> t = RTypes.Extractor.extract_type(:inet, :port_number, [])
  iex> match?({:type, _, :range, [{:integer, _, 0}, {:integer, _, 65535}]}, t)
  true

  iex> t = RTypes.Extractor.extract_type(Keyword, :t, [{:type, 0, :list, []}])
  iex> match?({:type, _, :list, [{:type, _, :tuple, [{:type, _, :atom, []}, {:type, _, :list, []}]}]}, t)
  true