crocks icon indicating copy to clipboard operation
crocks copied to clipboard

Add `applyTo` to all `Apply` ADTs

Open evilsoft opened this issue 7 years ago • 1 comments

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:

// 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.

evilsoft avatar Feb 13 '18 21:02 evilsoft

Hey, mind if I take a stab at this one? I've created a branch & impl'd a first cut at Async's applyTo here.

I've tested it out with other applicatives and it works swimmingly.

pfgray avatar Sep 19 '18 23:09 pfgray