3 ms·
The example applicative still respects sequencing - to do what the last paragraph claims to be doing you'd need to use some kind of nondeterministic gather. Ho
by lmm 12y ago
The example applicative still respects sequencing - to do what the last paragraph claims to be doing you'd need to use some kind of nondeterministic gather.
Honestly I think the differences in that example are pretty superficial. The real advantage of applicative is that because the assumptions are weaker, some things that aren't Monads are Applicatives.
- eru 12y agoThat's also why Applicatives combine better.
- tel 12y agoApplicatives can be analyzed without outside information. Applicatives are also closed under composition (and thus there's no need for the entire "transformer" concept). As far as I'm aware, nearly every functor admits at least one applicative structure and oftentimes many choices thereof.
- sfvisser 12y ago>Honestly I think the differences in that example are pretty superficial. For most instances the difference is superficial, but for some problem domains the difference can have a pretty big impact. All of this is because Applicative composition (using apply) statically guarantees there is no data dependencies between the (possibly) effectful computations. Monadic composition (using bind) can (but might not) introduce a data dependency which can only be reasoned about at runtime. Facebook's Haxl project is an interesting example of this: http://www.cs.ox.ac.uk/ralf.hinze/WG2.8/31/slides/simon.pdf http://www.cs.ox.ac.uk/ralf.hinze/WG2.8/31/slides/simon.pdf