Announcing cakeless - better reader monad for cake pattern

I’m glad to announce 0.1-SNASHOT version of https://github.com/itkpi/cakeless

Cakeless is library providing better reader monad for well-known cake pattern. It’s implemented using cats and shapeless.
The main abstraction cakeless provides is CakeT monad.
The library automaticaly infers abstract def s and val s (e.g. dependencies that should be provided) of the component stack, picks them up on the typelevel (as HList ) and wraps them into CakeT monad.
You can combine several cakes using flatMap. It will merge cakes dependencies using shapeless.ops.hlist.Union.
Dependencies from different cakes will be accumulated along with computaitons
Repeating dependencies (with same compile-time type) will be merged into one.

Addionally cakeless contains 2 separate modules:

  • integration with cats-effect for safe components allocation and releasing resources (using bracket)
  • module for managing component lifecycle (preStart, postStart like in akka actors)

If you’re bored by instantiating cakes by hands and planning to use other dependency injection library, Cakeless will allow you to do so quickly without rewriting existing components!

New contributors are also welcome =)

2 Likes

Very neat! I’m often scornful of the cake pattern, because it doesn’t provide enough lifecycle management for my real-world applications and because it gets tied up in knots with the number of components I’m managing, but this sounds like you’re making it much more realistic…

1 Like

Thank you for your feedback =)
I would like you to give suggestions about what to add into the library if you have any ideas

Not directly in the topic, but why is the cake pattern called “cake” pattern?

“Stackable traits” is better description for this pattern.
That’s because you stack traits like cake layers ))