News for hackers. Stuff that matters.
Re:Modern Functional Programming: The Onion Architecture by mej10 on Thursday September 29, 2016 @09:43PM (#12610062)
You can achieve this level of control using monad transformers or extensible effects -- this is a standard technique in Haskell.

    frignate :: (MonadDB m) => Config -> m Int
    frignate cfg = do
      db <- getDB
      ...
      return 1
And it is composable, so if a function calls a function that uses one of the managed resources then the requirement propagates upward.

And you can swap in non-IO based instances for testing, or whatever else you want.

There are no comments on this comment yet.