Skip to content

Instantly share code, notes, and snippets.

@Wizek
Last active February 20, 2016 22:22
Show Gist options
  • Select an option

  • Save Wizek/8a8f02e63f14933a0091 to your computer and use it in GitHub Desktop.

Select an option

Save Wizek/8a8f02e63f14933a0091 to your computer and use it in GitHub Desktop.
Thinking about how Dependency Injection could work in Haskell similar to Angular.js, to allow for mocking in unit tests, therefore most easily testing even IO code or complex pure code.
fns =
[ ("a", ["print", "b"], \print b -> print b)
, ("b", [], 12)
, ("print", [], print)
]
main = assemble fns `lookup` "a"
spec = do
b' =? 3
a' =? 12
where
b' = assemble ([("b", [], 3)] ++ fns) `lookup` "b"
a' = assemble ([("print", [], id)] ++ fns) `lookup` "a"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment