PLS Lab

Selective functors

An applicative functor is selective just when it comes with a certain kind of 'selection' operator. Intuitively, the selection operator - which replaces the 'bind' operator of monads - allows conditional choice on when effects are meant to run.

In Haskell

Selective functors are encapsulated by the type class

class Applicative f => Selective f where
  select :: f (Either a b) -> f (a -> b) -> f b

where Applicative f is the type class of applicative functors.

Every monad gives rise to a selective, but not vice versa.

Categorically

While there are no particular comments in the paper that introduced them, it seems like selective functors come with a lax monoidality

m_{A, B} : F(A + B) \to F(A) + F(B)

Given f : A \to B, this may be used to construct a morphism

  F(A + B)
\xrightarrow{m_{A, B}}
  F(A) + F(B)
\xrightarrow{F(f) + \text{id}}
  F(B) + F(B)
\xrightarrow{[\text{id}, \text{id}]}
  F(B)

References

Mokhov, Andrey, Georgy Lukyanov, Simon Marlow, and Jeremie Dimino. 2019. ‘Selective Applicative Functors’. Proceedings of the ACM on Programming Languages 3 (ICFP). https://doi.org/10.1145/3341694.
@article{mokhov_selective_2019,
	title = {Selective applicative functors},
	volume = {3},
	doi = {10.1145/3341694},
	number = {ICFP},
	journal = {Proceedings of the ACM on Programming Languages},
	author = {Mokhov, Andrey and Lukyanov, Georgy and Marlow, Simon and Dimino, Jeremie},
	month = jul,
	year = {2019}
}