{"id":17908797,"url":"https://github.com/iequ1/typerefl","last_synced_at":"2025-09-05T11:32:52.773Z","repository":{"id":38314154,"uuid":"184647794","full_name":"ieQu1/typerefl","owner":"ieQu1","description":"Use Erlang typespecs in the runtime","archived":false,"fork":false,"pushed_at":"2024-11-10T23:08:54.000Z","size":122,"stargazers_count":39,"open_issues_count":7,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T23:41:22.727Z","etag":null,"topics":["erlang","reflection","typechecker"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ieQu1.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-02T20:33:31.000Z","updated_at":"2025-01-08T11:20:50.000Z","dependencies_parsed_at":"2024-10-28T19:18:40.178Z","dependency_job_id":"f42cd0ff-97ac-47c2-8f31-312f17d590d8","html_url":"https://github.com/ieQu1/typerefl","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ieQu1%2Ftyperefl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ieQu1%2Ftyperefl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ieQu1%2Ftyperefl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ieQu1%2Ftyperefl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ieQu1","download_url":"https://codeload.github.com/ieQu1/typerefl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245164894,"owners_count":20571204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["erlang","reflection","typechecker"],"created_at":"2024-10-28T19:17:54.832Z","updated_at":"2025-03-23T20:31:12.297Z","avatar_url":"https://github.com/ieQu1.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"#+TITLE: Typerefl\n\nThis library reifies dialyzer types as ordinary Erlang functions. It\nenables e.g. validation of terms against dialyzer typespecs in the\nruntime.\n\n* Talk is cheap, show me the code\n\nSimple example using builtin types:\n\n#+BEGIN_SRC erlang\n-include_lib(\"typerefl/include/types.hrl\").\n\nmain() -\u003e\n  %% Define type (in the term Universe!)\n  Type = {foo, non_neg_integer(), #{atom() =\u003e integer()}},\n  %% Valid term:\n  ok = typerefl:typecheck(Type, {foo, 3, #{bar =\u003e 42}}),\n  %% Invalid term:\n  {error,\"Expected: {foo, non_neg_integer(), #{atom() =\u003e integer()}}\\nGot: 1\\n\"} =\n    typerefl:typecheck(Type, 1).\n#+END_SRC\n\nHigher kind recursive types are of course supported too:\n\n#+BEGIN_SRC erlang\n-include_lib(\"typerefl/include/types.hrl\").\n\n-type stupid_list(A, B) :: {cons, A, stupid_list(A, B)} | B.\n\n-type stupid_list(A) :: stupid_list(A, nil).\n\n%% Any dialyzer type can be reified:\n-reflect_type([stupid_list/1]).\n\nmain() -\u003e\n  ok = typerefl:typecheck(stupid_list(atom()), {cons, foo, nil}),\n  {error, _} = typerefl:typecheck(stupid_list(atom()), {cons, 1, nil}).\n#+END_SRC\n\nMaps:\n\n#+BEGIN_SRC erlang\n\n-include_lib(\"typerefl/include/types.hrl\").\n\n-type foo() :: #{ foo := integer()\n                , bar := atom()\n                , integer() =\u003e list()\n                }.\n\n-reflect_type([foo/0]).\n\nmain() -\u003e\n  ok = typerefl:typecheck(foo(), #{foo =\u003e 1, bar =\u003e foo, 1 =\u003e []}).\n#+END_SRC\n\nThis library typechecks pretty much anything that dialyzer does,\nexcept for functions. In the future it may support arity check.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiequ1%2Ftyperefl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiequ1%2Ftyperefl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiequ1%2Ftyperefl/lists"}