u/yanshuaiin r/scala • Recommends
Managing Effects in Domain Models - The Algebraic Way by Debasish Ghosh at #FnConf18
#algebraiceffects#domainmodeling#scala
14K subscribers • 16 videos on Hallway
Intermediate. Assumes working knowledge.
2.3K views7 years ago1 recommendation
Software designProgramming languagesFunctional programmingScalaDomain-driven design
Debasish Ghosh explains how to manage side-effects in domain models using algebraic effects in Scala while maintaining pure functional composition.
When we talk about domain models, we talk about entities that interact with each other to accomplish specific domain functionalities. We can model these behaviors using pure functions. Pure functions compose to build larger behaviors out of smaller ones. But unfortunately the real world is not so pure. We need to manage exceptions that may occur as part of the interactions, we may need to write stuff to the underlying repository (that may again fail), we may need to log audit trails and there can be many other instances where the domain behavior does not guarantee any purity whatsoever. The substitution model of functional programming fails under these conditions, which we call side-effects. In this session we talk about how to manage such impure scenarios using the power of algebraic effects. We will see how we can achieve function composition even in the presence of effects and keep our model pure and referentially transparent. We will use Scala as the implementation language. In discussing effects we will look at some patterns that will ensure a clean separation between the algebra of our interface and the implementation. This has the advantage that we can compose algebras incrementally to build richer functionalities without committing to specific implementations. This is the tagless final approach that offers modularity and extensibility in designing pure and effectful domain models. Details: confengine.com/functional-conf-2018/proposal/7763/managing-e… Conference: functionalconf.comu/yanshuaiin r/scala • Recommends