Skip to content
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

Build a generator for higher-order mixins #1

Open
tgrospic opened this issue Jun 13, 2020 · 0 comments
Open

Build a generator for higher-order mixins #1

tgrospic opened this issue Jun 13, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@tgrospic
Copy link
Owner

The big part of boilerplate code is when multiple algebras are combined with explicit implementation of algebra interface. For example state monad with either type.

public class StateEitherImpl<st, err>
: EitherAlg<Either<err>, err>
, ApplicativeAlg<Either<err>>
, MonadAlg<State<st>>
, AltAlg<State<st>>
, ThrowErrorAlg<State<st>, err>
, StateAlg<State<st>, Either<err>, st>
, TraversableAlg<Collection, State<st>>
, CollectionAlg<Collection>
, FunctorAlg<Collection>
, PlusAlg<Collection>
, FoldableAlg<Collection> {

The good news is that this complete class can be generated automatically with the help of any off-the-shelf dependency injection library. Just basic constructor injection can do the trick. Visual Studio already has support to generate this pattern, including with method body if implementing interface is supplied in the constructor.

Very similar thing exists for Scala to generate composed instances.
https://github.com/b-studios/MixinComposition

@tgrospic tgrospic added the enhancement New feature or request label Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant