Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is an interesting concept, but it is presented so abstractly as to be opaque to even most functional programmers, I think.

The basic idea, as I understand it, is a typeclass that is more powerful than an applicative, but still less powerful than a monad, called a "selective applicative". I would summarize them like this:

* Applicative: Fixed computation graph, but no conditional structure.

* Selective applicative: Fixed computation graph with some conditional "branches".

* Monad: Dynamic computation graph and control flow, can generate new structure on the fly.

I'm sure I'm still missing a lot, but I think that's the 10,000 foot view.



That matches what I managed to glean, though I didn't get much further.

It started making more sense though when I managed to fully understand the AST comparison that was being made. Specifically, this approach lets you do the LISPy "code is data" thing where you can construct your program within your program and then run it, but instead does it via "data is execution+control-flow". Thus gaining the benefits of static analysis on the constructed program since you wrote it all out in the "normal"/static order rather than the "nested"/dynamic view of a program that monads give.

At least that's the gist I got, though take it with a grain of salt, the article went very over my head at times.


https://chrispenner.ca/posts/expressiveness-spectrum has some good examples showing why one might want selectives (then continues to explore arrows https://chrispenner.ca/posts/arrow-effects )


Where do Hughes's Arrows fit in?


In this particular case, Hughes’ arrows are a practical implementation of a Profunctor Categorical Structure. They are roughly a generalization of what arrows (as in function types or more accurately relations) are.

In the article, author is pointing out that the selective applicative doesn’t seem to work correctly (in a categorical sense) for functions, but when generalizing to profunctors a near semi-ring structure appears and works for the SApplicative.

I am pretty sure I’m reading TFA correctly here, but I’ll check when off mobile and edit if I still can.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: