#readwise # Applicative Functors ![rw-book-cover](https://blog.ploeh.dk/assets/themes/ploeh/images/favicons/favicon.png) ## Metadata - Author: [[Mark Seemann]] - Full Title: Applicative Functors - URL: https://blog.ploeh.dk/2018/10/01/applicative-functors/ ## Summary This is article is a part of a bigger blog series that covers various topics from category theory. The series includes other articles on the topic of applicative functors. Here's a list, retrieved on March 17, 2023. - [[Full deck]] - [[An applicative password list]] - [[Applicative combinations of functions]] - The Maybe applicative functor - [[Applicative validation]] - [[The Test Data Generator applicative functor]] - Danish CPR numbers in F# - The Lazy applicative functor - Applicative monoids ## Highlights - I find it helpful to think of applicative functors as an abstraction that enable you to express *combinations* of things. ([View Highlight](https://read.readwise.io/read/01gvr9c8yj8y3m9ew115c6sepd)) ^lxdtwe - A normal functor maps objects in an 'elevated world' (like C#'s `IEnumerable<T>` or `IObservable<T>`) using a function in the 'normal world'. As a variation, an applicative functor maps objects in an 'elevated world' using functions from the same 'elevated world'. ... In [Haskell](https://haskell.org), an applicative functor is defined *like* this: ```haskell class Functor f => Applicative f where pure  :: a -> f a (<*>) :: f (a -> b) -> f a -> f b ``` `pure` is easy to understand. It simply 'elevates' a 'normal' value to a functor value. ... The `<*>` operator applies an 'elevated' function to an 'elevated' value. ... Perhaps you can already see what I meant by *combinations* of things. - If you need `list` to be applicative, `pure` should have the type `'a -> 'a list`, and `<*>` should have the type `('a -> 'b) list -> 'a list -> 'b list`. ([View Highlight](https://read.readwise.io/read/01gvr9q3505w7jxebms0g4s4kj)) ^blxqsh - If you need `option` to be applicative, `<*>` should have the type `('a -> 'b) option -> 'a option -> 'b option`. ([View Highlight](https://read.readwise.io/read/01gvr9rswf4d6h70219m5d5xmr)) - As you can see, here you somehow have to figure out how to combine a sequence of functions with a sequence of values. ([View Highlight](https://read.readwise.io/read/01gvr9tn0hxw6pg2ytb8a9mted)) ^xunzc6 - I find it helpful to think of applicative functors as an abstraction that enables you to model arbitrary *combinations* of objects. ([View Highlight](https://read.readwise.io/read/01gvra2v8wrm5fwbggxmhycaba))