-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typeclasses implicit objects #264
Conversation
…h reification system
Codecov Report
@@ Coverage Diff @@
## master #264 +/- ##
=========================================
Coverage ? 45.57%
Complexity ? 315
=========================================
Files ? 143
Lines ? 3721
Branches ? 423
=========================================
Hits ? 1696
Misses ? 1891
Partials ? 134
Continue to review full report at Codecov.
|
@@ -1,6 +1,6 @@ | |||
package kategory | |||
|
|||
interface FunctionK<in F, out G> { | |||
interface FunctionK<F, G> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have they lost their variance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inferred types with the type-literal in java reflection not liking contravariant positions. Also these are usually mapped to root ADTs and typeclasses which are just invariant positions AFAIK.
… into rr-typeclasses-implicit-objects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic!
This allows Typeclasses instances of arbitrary arity to be discovered implicitly by providing a default factory based on naming conventions that can be used to lookup the instance.
It also introduces granularity in the typeclass definitions for better composition.
Fixes #260
Example on
EitherTFunctorInstance
You can now safely invoke without prior registration:
Note the
EitherT
Functor
instance depends on theFunctor<F>
. Kategory can now automatically resolve constrains recursively as declared in theEitherTFunctorInstanceImplicits#instance
arguments.Once all instances are migrated I will introduce a new processor
@typeclass
which generates the implicit object automatically and also the companion helpers for the datatype that the instance is targeting in the same way now@deriving
does.As a final pass we will remove all calls that manually provide instances that can be resolved implicitly in reified contexts.