title: Dependency injection in Haskell: solving the task idiomatically
body: <p>What is the idiomatic Haskell solution for dependency injection?</p>
  
  <p>E.g., suppose you have an interface <code>frobby</code>, and you needed to pass an instance conforming to <code>frobby</code> around (there might be multiple varieties of these instances, say, <code>foo</code>, and <code>bar</code>).</p>
  
  <p>Typical operations would be:</p>
  
  <ul>
  <li><p>functions that take some value <code>X</code> and return some value <code>Y</code>. E.g., this might be a database accessor, taking a SQL query &amp; a connector and returning a dataset. You might need to implement postgres, mysql, and a mock test system.</p></li>
  <li><p>functions that take some value <code>Z</code> and return a closure relating to <code>Z</code>, specialized to a given <code>foo</code> or <code>bar</code> style, chosen at runtime.</p></li>
  </ul>
  
  <p>One person solved the problem as follows: </p>
  
  <p><a href="http://mikehadlow.blogspot.com/2011/05/dependency-injection-haskell-style.html">http://mikehadlow.blogspot.com/2011/05/dependency-injection-haskell-style.html</a></p>
  
  <p>But I don't know if that's the canonical way to manage this task.</p>