arrow-meta
arrow-meta copied to clipboard
Type Class Discovery & Resolution
With compiler plugins is very likely we can implement full-blown type classes including resolution and automatic derivation.
Type class derivation
- By default look first for user declared extensions following the KEEP-87 candidate resolution.
- (User) Denote type class instances as derivable by annotating the annotation method flagged as
@derivable. For example inFunctor<F>@derivable Kind<F, A>.map...`. - Intercept declaration and class building phase to scan all
interfacewhich contains a single type argument. These are the type class candidates. - Intercept declaration and class building phase of all types in search for compatible matches that can be used to implement the
@derivablemethod if it exists. If the type class contains no derivable method we stop otherwise we try to find a compatible match. In this step we also want to skip types that already include instances for this type class following the KEEP 87 resolution rules. - When a matching type is found for a derivable method we can create automatically a type class instance for it and enrich the data type companion with the typeclass instances as a property.
- This can potentially be done in the
ClassBuilderInterceptorExtensionphase.
Call site resolution
- For all expressions that make a call into a type class constrained function look for instances that may be injected with the same resolution rules at KEEP-87
This feature should be part or is closely related with arrow-kt/arrow#1638
Currently being implemented with Type Proofs