3 ms·
Monadic functional languages have native support for dependency injection and typeclasses/interfaces provide interoperability and easy mocking or alternative im
by fabianhjr 4y ago
Monadic functional languages have native support for dependency injection and typeclasses/interfaces provide interoperability and easy mocking or alternative implementations with type-checking / propagation of which dependency they are using. (As to avoid mismatching between mocks and a real implementation for example)
https://itnext.io/hmock-first-rate-mocks-in-haskell-e59d7c3b066c https://itnext.io/hmock-first-rate-mocks-in-haskell-e59d7c3b...
- hota_mazi 4y agoThis article is just about mocks and doesn't really touch on dependency injection at all, and Haskell simply doesn't have the mechanisms to supply the kind of implicit passing that useful DI requires.
- jose_zap 4y agoSounds like you are taking about ReaderT, which is a common way of implicitly passing more data to functions. There are many other ways, though.
- hota_mazi 4y ago`Reader` and `ReaderT` are not implicit at all, they still need to pass parameters explicitly. What other ways do you have in mind? I am not aware of any Haskell functionality or compiler flag that enables implicit parameter passing, like Java, Kotlin, and Rust allow.
- jose_zap 4y agohttps://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/implicit_parameters.html https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/impl...