Erlang dynamic typecheck with sheriff
Threre are parse-transform for type-checking erlang values in runtime.
https://github.com/extend/sheriff.git
Here is an example:
-compile({parse_transform, sheriff}).
-type my_type() :: {integer(), binary()}.
check_some_types(Val) ->
true = sheriff:check(Val, my_type),
true = sheriff:check(Val, {external, type}),
true = sheriff:check(Val, "external:type()"),
true = sheriff:chack(Val, "{integer(), binary()}").
Function sheriff:check/2
return true
or false
on success or error.
It supports internel types (defined in module), external (exported in other module) and inline types (defined in string).
At the moment it does not support types in variables like: sheriff:check(Val, Type)
but we are working on it)
Written by Daniil
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Erlang
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#