I’ve been playing at writing a toy dependency injection framework that uses dynamic types under the hood. The cauldron library is the result. Basically, it wires a bunch of component constructors for you, so you don’t have to do it manually at the composition root of your app.
By “components” (or “beans”) I mean a bunch of records-of-functions with effects in IO
. A way of structuring applications that doesn’t even use the ReaderT
monad. Components get their dependencies as regular parameters, and that’s it. (I’m actually curious about why this architecture isn’t more popular in Haskell-land. Why reach always for ReaderT
, transformers, or other effect systems?)
Anyway, the good news is that it seems to work. The bad news is that it doesn’t seem less verbose that wiring things manually. For comparison, here is a manual wiring of some toy components, and here is the same wiring using Cauldron.
In any case, this project has helped me learn about dynamically typed Haskell. Type.Reflection
, Data.Typeable
, Data.Type.Equality
and all that. It’s actually a fun and useful part of the language!