opened 11:09AM - 08 Jun 23 UTC
I would like to add these two methods, as well as their default implementations,… to `Data.Bitraversable`:
```haskell
class Bitraversable t where
bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> t a b -> f (t c d)
firstA :: Applicative f => (a -> f c) -> t a b -> f (t c b)
firstA f = bitraverse f pure
secondA :: Applicative f => (b -> f c) -> t a b -> f (t a c)
secondA f = bitraverse pure f
```
The motivation here is as follows:
1. In my experience, in app code, wanting to only act based on one part of a `Bitraversable` (most commonly `Either`) is more common than wanting to act on both via `bitraverse`
2. `Data.Bifunctor` which is the "parent" of `Data.Bitraversable` contains the specialised functions `first` and `second` which only map the left and the right arguments of the `Bifunctor`, and it seems like a slight inconsistency to not have them here as well.
3. I think these functions are a really safe bet, in that I think that there is not much danger of a new proposal coming later down the line suggesting breaking changes to these functions.
This is due to the fact that I **think** there are not many opinions or different paths that can be taken on how these functions
should look, hence adding these functions is not a matter of pinning down which API is the most convenient/general/etc, but
rather a matter of filling in something that has only one possible type signature and name.
Here are my thoughts on why the type signatures and names for these functions are predetermined:
1. The type signatures of these functions can't really vary. This is IMO already pinned down by the correspondence between
2. `fmap` and `traverse`, as well as the correspondence between `bimap` and `first`+`second`.
3. Their naming can't vary that much as well, for the sake of consistency with `bimap` and `first`+`second`, as well as the `-A`
suffix convention.
4. Their default implementation is clear as well, and making them class members of `Bitraversable` allows for freedom for any
users who want to do other things.
2\. is also the motivation for their naming, combined with the convention that an `A` suffix means "the same function but in an `Applicative` context".
An "exact" Hackage search for these identifiers does not seem to bring up many occurrences, so breakage should be extremely limited or non-existent:
* https://hackage-search.serokell.io/?q=%5CbfirstA%5Cb - two occurrences, they do something completely different it seems
* https://hackage-search.serokell.io/?q=%5CbsecondA%5Cb - no occurrences.