View Source cure_instance_registry (cure v0.7.0)

Summary

Types

compiled_method/0

-type compiled_method() :: {module(), atom(), arity()}.

instance_entry/0

-type instance_entry() ::
          #instance_entry{typeclass :: atom(),
                          type_key :: term(),
                          methods :: #{atom() => compiled_method()},
                          priority :: integer(),
                          registered_at :: erlang:timestamp()}.

type_key/0

-type type_key() :: term().

typeclass/0

-type typeclass() :: atom().

Functions

clear_cache()

-spec clear_cache() -> ok.

code_change(OldVsn, State, Extra)

get_all_instances(Typeclass)

-spec get_all_instances(typeclass()) -> [instance_entry()].

get_method(Typeclass, MethodName, ReceiverType)

-spec get_method(typeclass(), atom(), term()) -> {ok, compiled_method()} | {error, term()}.

handle_call(Request, From, State)

handle_cast(Request, State)

handle_info(Info, State)

init(_)

lookup_instance(Typeclass, Type)

-spec lookup_instance(typeclass(), term()) -> {ok, instance_entry()} | not_found.

register_instance(Typeclass, Type, Methods)

-spec register_instance(typeclass(), term(), #{atom() => compiled_method()}) -> ok | {error, term()}.

register_instance(Typeclass, Type, Methods, Priority)

-spec register_instance(typeclass(), term(), #{atom() => compiled_method()}, integer()) ->
                           ok | {error, term()}.

start_link()

-spec start_link() -> {ok, pid()} | {error, term()}.

stop()

-spec stop() -> ok.

terminate(Reason, State)