TypeResolver
is a library, that provides a macro to resolve typespecs. It returns a native type that is represented in easy to handle structs. A native type is a type defined of typespec built-ins - no more user types are referenced, type parameters were resolved, …
E.g. the following call
TypeResolver.resolve(integer() | String.t())
will result in
%TypeResolver.UnionT{
inner: [%TypeResolver.Types.IntegerT{}, %TypeResolver.Types.BinaryT{}]
}
TypeResolver
doesn’t need any compiler modifications and works with macros only.
We saw the need for such a library, since we haven’t found a simple solution to resolve and handle typespecs easily. Using TypeResolver
we can now lift typespecs into run time. At some point we will e.g. release a TypedStruct plugin that derives validation based on typespecs.
Happy coding!