Add `applyTo` to all `Apply` ADTs
- Dominant language
- JavaScript
- Stars
- 1.6k
- Forks
- 103
- PR merge metrics
- No merged PRs in 30d
Description
This is the first step in 💯 fantasy-land integration of `ap`. Will define `applyTo` on all `Apply` types which will match the fantasy-land signature. This will be the method that will eventually map to `fantasy-land/ap`.
In order to handle proper error reporting, method will be need to take in the method name as context:
```js
// applyTo :: Apply m => m a ~> m a -> m (a -> b) -> m b
const applyTo = name => m => (...)
```
This will be provided for the following types:
- [ ] `Async`
- [ ] `Const`
- [ ] `Either`
- [ ] `IO`
- [ ] `Identity`
- [ ] `List`
- [ ] `Maybe`
- [ ] `Pair`
- [ ] `Reader`
- [ ] `Result`
- [ ] `State`
- [ ] `Unit`
- [ ] `Writer`
Initially we will not provide a point free function for this method as there is a combinator named `applyTo` that is used for applying a value to functions...We will need to do a breaking change and some function name juggling:
* mv `combinators/applyTo` -> `combinators/applyWith`
* mv `combinators/reverseApply` -> `pointfree/applyTo`
* Update `pointfree/applyTo` to take either (value, function) OR (m value, m function) where m is an Apply of the same type. It should error unless those pairs are exactly met.
Contributor guide
Assessment
This issue has not been assessed yet.