Last active
February 20, 2016 22:22
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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