Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an If-Then-Else operation to the Apply. (#2609)
* Add an If-Then-Else operation to the Apply. The `FlatMap` type-class includes a function `ifM`, which allows evaluating a Boolean computation and, depending on the result, choosing between one effectful computation or other. We add to the `Apply` type-class a very similar function. Although the function is similar to `ifM`, there is an important difference between them, as to how they handle the effect: - The `ifM` will run the effects of the condition `F[Boolean]`, followed by the effects of _only one_ of the branches. - The `ifA` will always run the effect of the condition, that of the first branch, and that of the second branch, in that order. Thus, the if-then-else part in `ifA` only applies to the inner values, not to the effects. * Avoid adding methods to the type class. To preserve binary compatibility, we can not add methods to an existing type-class, and can only use the syntax extension. * Add traits for Binary Compatibility. * Attend code review comments.
- Loading branch information