Applicative functor

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

In functional programming, an applicative functor is a structure intermediate between functors and monads, in that they allow sequencing of functorial computations (unlike plain functors) but without deciding on which computation to perform on the basis of the result of a previous computation (unlike monads). Applicative functors are the programming equivalent of lax monoidal functors with tensorial strength in category theory.

Applicative functors were introduced in 2007 by Conor McBride and Ross Paterson in their paper Functional Pearl: applicative programming with effects.[1]

Applicative functors first appeared as a library feature in Haskell, but have since spread to other languages as well, including Idris, Agda, and Scala. Both Glasgow Haskell and Idris now offer language features designed to ease programming with applicative functors. In Haskell, applicative functors are implemented in the Applicative type class.

Relationship to monads[edit]

Due to historical accident, in the Haskell language, applicative functors were not implemented as a superclass of Monad, but as a separate type class. It turned out that, in practice, there was very little demand for such a separation, so in 2014, it was proposed to make Applicative retroactively a superclass of Monad.[2]

See also[edit]

References[edit]

  1. ^ McBride, Conor; Paterson, Ross (2008-01-01). "Applicative programming with effects". Journal of Functional Programming. 18 (01): 1–13. doi:10.1017/S0956796807006326. ISSN 1469-7653.
  2. ^ "Functor-Applicative-Monad Proposal - HaskellWiki". wiki.haskell.org. Retrieved 2016-04-06.