What is the idiomatic Haskell solution for dependency injection?
E.g., suppose you have an interface frobby, and you needed to pass an instance conforming to frobby around (there might be multiple varieties of these instances, say, foo, and bar).
Typical operations would be:
functions that take some value
Xand return some valueY. E.g., this might be a database accessor, taking a SQL query & a connector and returning a dataset. You might need to implement postgres, mysql, and a mock test system.functions that take some value
Zand return a closure relating toZ, specialized to a givenfooorbarstyle, chosen at runtime.
One person solved the problem as follows:
http://mikehadlow.blogspot.com/2011/05/dependency-injection-haskell-style.html
But I don't know if that's the canonical way to manage this task.