Skip to main content

src/girard@types.erl

-module(girard@types).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/girard/types.gleam").
-export_type([type/0, scheme/0, error/0]).

-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.

?MODULEDOC(
    " The public type vocabulary girard reports: the inferred `Type` model and the\n"
    " `Error` describing why a module could not be typed. The inference engine and\n"
    " its helpers are implementation detail and live under `girard/internal/*`.\n"
).

-type type() :: {named, binary(), binary(), list(type())} |
    {fn, list(type()), type()} |
    {var, integer()} |
    {tuple, list(type())}.

-type scheme() :: {scheme, list(integer()), type()}.

-type error() :: {type_mismatch, type(), type()} |
    arity_mismatch |
    {recursive_type, integer(), type()} |
    {unbound_variable, binary()} |
    {unknown_constructor, binary()} |
    {unknown_module, binary()} |
    {no_such_export, binary(), binary()} |
    {no_such_field, binary(), binary()} |
    not_a_record |
    not_a_tuple |
    {tuple_index_out_of_range, integer()} |
    {unknown_label, binary()} |
    ambiguous_call |
    missing_argument |
    {unsupported, binary()} |
    {parse_failed, glance:error()}.