KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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 X and return some value Y . 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 Z and return a closure relating to Z , specialized to a given foo or bar style, 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.
Tags (comma-separated)
Save Edits
Cancel