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

I find Applicatives very useful.

Applicative computations have effects and return a value. They can be combined but only in a restricted way that ensures that the effects of one of the computations do not depend on the value returned by another.

For example, if you read a person's bio and photo from two independent files and combine them into a Person value, that fits the Applicative model.

However, if the path to the photo file were included in the bio file and not known beforehand, that wouldn't fit the Applicative model, because one of the effects (reading the photo) depends on the result value of the other.

So why have this limitation, and why create a separate interface for it?

- For one, Applicatives are more "analyzable" than unrestricted monadic computations. You can identify the separate stages of a computation, collect estimates of required resources, etc.

- Some effects like concurrency, validation, and context-free language parsing fit the Applicative mold very well.

- Combinations of different Applicative effects are themselves applicative. If you have a computation that reads a file and validates the resulting data (a combination of Applicative effects) the combined effect is Applicative and can be combined with other effects of the same type.



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

Search: