Skip to content

Using Arrows for Dependency Handling

jaspervdj.be
14 pointsnudded3 comments
On HN

Comments

If anyone can explain to me why monads are insufficient, that would be swell. I'm really not going to get it on my own any time soon.

Author of the article here. I'll try to give a quick informal explanation. If you look at the type signature of `>>=`:

  m a -> (a -> m b) -> m b
Let's suppose there's a HakyllAction monad. The >>= signature would be:
  HakyllAction a -> (a -> HakyllAction b) -> HakyllAction b
If we implement this operator, we get a value `HakyllAction a` and a function `a -> HakyllAction b`. We can look at the dependencies of the value, but we don't have access to the dependencies of the `a -> HakyllAction b`. If we want that, we need to apply it to the first value.

This goes against the idea of dependency handling -- we want to know the dependencies first, and then only execute the function if needed.

Hope this helps.

This helps very much, thanks! :)

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.