|
|
|
|
|
by hota_mazi
2987 days ago
|
|
> monad transformers (the promise of aspect oriented programming actually realized) I hardly see any overlap between these two concepts. AOP is about cross cutting concerns and being able easily insert similar functionalities in unrelated areas of the code. Monad transformers are the hack you need to use to make monads compose. |
|
Monad transformers allow one to slice up the functionality and concerns of a program in a dimension different from slicing of a program into components that are then composed together; e.g. a bunch of functions that call each other or a bunch of objects that pass messages between themselves.
Each monad transformer in a transformer stack adds functionality and concerns that the other parts of the stack don't need to care about. Components can then be written polymorphically in the concerns they care about allowing them to be instantiated wherever the capabilities they need are present. Ultimately a program is instantiated to a particular transformer stack and then it is supplied effect handlers that reduce it to the base monad (often IO). The ability to modify functionality in a cross-cutting way is concentrated in the effect handler which is at the discretion of the call site, not the implementation site.
This is not quite AOP but it's in the same space. It's hard to see in small apps but quickly emerges as the scale of a Haskell application grows.