Open raulraja opened 5 years ago
Does this use inline classes or?
The idea is that this will take a class and creates a new class which includes the instances and derivation all in one step:
@type typealias ListK<A> = List with Monad<ForListK>
Is the entire declaration for the ListK
implementation.
At the same time if you try to create impossible types:
@type typealias MyValidated<E, A> = Validated<E, A> with Monad<ValidatedPartial<E>>
// compiler bails because it can't find `flatMap` on `Validated` from which to derive Monad.
@pakoito this is equivalent to the impossible types in TypeclassLess but it manages the collisions and overrides for you so you can focus on one line in the semantics.
It could use inline classes for primitive wrapped types though:
@type typealias CombinableString = String with Semigroup<String>
generates:
inline class CombinableString(val value: String) {
companion object {
val semigroup: Semigroup<String> = ...
}
}
Option is automatically materialized as a new type which combines the runtime of Either alongside its Monad API as synthetic injected methods