Diagonally in Data.Bimap
Joachim Breitner
mail at joachim-breitner.de
Thu Jul 5 15:10:19 UTC 2018
Hi
Am Donnerstag, den 05.07.2018, 15:36 +0200 schrieb Gabor Greif:
> Hi!
>
> Just searched for a `bimap` variant that simultaneously transforms
> both components with the same morphism:
>
> ``` haskell
> diag :: Bifunctor p => (a -> b) -> p a a -> p b b
> diag f = bimap f f
> ```
>
> I did not find any. Would it make sense to add it?
possibly, I have wanted it too before.
Bikeshedding:
I’d have expected the name “both”. It also has precedence here:
http://hackage.haskell.org/package/extra/docs/Data-Tuple-Extra.html#v:both
http://hackage.haskell.org/package/concatenative/docs/Control-Concatenative.html#v:both
http://hackage.haskell.org/package/MissingK/docs/Control-Arrow-Extra.html#v:both
http://hackage.haskell.org/package/lens-family/docs/Lens-Family2-Stock.html#v:both
http://hackage.haskell.org/package/lens/docs/Control-Lens-Traversal.html#v:both
Diagonally sounds more like something of type `a -> (a,a)` or similar.
> PPS: I would have sent this to libraries at haskell.org but it seem to be
> closed group.
It should not. Maybe only open to subscribers? (A common crude anti-
spam measurement.)
Cheers,
Joachim
--
Joachim Breitner
mail at joachim-breitner.de
http://www.joachim-breitner.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20180705/612a9705/attachment.sig>
More information about the ghc-devs
mailing list