3 ms·
Admittedly non-illuminating, and maybe even misleading, musings: I like to think of free monads and related constructions as dependency injection "turned insid
by danidiaz 11y ago
Admittedly non-illuminating, and maybe even misleading, musings:
I like to think of free monads and related constructions as dependency injection "turned inside out". With dependency injection, you configure a foozle in various ways, and then the foozle controls how and when to use the injected components. The foozle is on the outside; the dependencies, once injected, are on the inside.
With a free monad, the foozle (the "logic" of the application) is on the inside, and an outside interpreter is the one that services all the "effect requests". The foozle is "run" by the interpreter.
That's the basic idea. Then there are practical concerns of how to make it fast enough, of how to be able to handle different combinations of effects (environment reads, state, io requests...) without requiring boilerplate, and so on.
- plonh 11y agoThat's Inversion of Control , not Dependency Injection .