arliss_obsidian/fp/Classes/Functor/Applicative.md
Orion Kindel d74fc46755
update
2024-09-24 14:53:59 -05:00

18 lines
445 B
Markdown

Adds the `pure` [[Functions|function]] to [[Apply]], allowing arbitrary values to be wrapped in a [[Functor]].
```haskell
class Apply f <= Applicative f where
pure :: forall a. a -> f a
```
### Examples
`pure a` in various types:
type|equivalent to
---|---
[[Array]]|`[a]`
[[List]]|`Cons a`
[[Maybe]]|`Just a`
[[Either]]|`Right a`
[[Effect]]|`() => a`<sup><i>more or less</i></sup>
[[Aff]]|`Promise.resolve(a)`<sup><i>more or less</i></sup>