<div dir="ltr">hi,<div><br></div><div>i keep trying to find something that feels terribly obvious but i can't make any link.</div><div><br></div><div>say i have a function of the following type:</div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">foo :: (a, b) -> ([a], [b]) -> ([a], [b])</font></div><div><font face="monospace, monospace">or perhaps more generally:</font></div><div><font face="monospace, monospace">foo :: SomeClass f => f a b -> f [a] [b] -> f [a] [b]</font></div><div><br></div><div>is SomeClass supposed to be BiFunctor or something else?</div><div>clearly, what i want to do is to combine the elements of the first pair into the elements of the second, preferrably without pattern matching, that is, merely in function of (:).</div><div><br></div><div>i think the problem with bifunctor is that it seems to only allow the application of both arguments in a separate fashion. but here the first argument is in one block, that is (a,b).</div><div>i know, ofc we could do something like:</div><div>foo pair pairList = bimap (fst pair :) (snd pair:) pairList</div><div>or maybe use curry or whatever. but i'd like my pair to not need to be unboxed!</div><div><br></div><div>is there not a way to not have to manually call fst and snd? are both of these functions typeclass methods by any chance? then we could write a generalized function that could work for any f = (:) or any kind of pair-like thingy. mind you i'm not sure to which extent it would keep the opacity of the type constructor (,).</div><div><br></div><div>especially, it's a bit like unboxing the Maybe type constructor: you can do it manually by pattern matching, but when you have the exact same issue but with IO, it's not possible anymore to unbox the underlying type</div><div>equally, i bet one could invent IO a b, in a way that you could not just get a and b, but you could somehow implement</div><div><font face="monospace, monospace">opaqueBimap :: (i -> k i) -> f a b -> f (k a) (k b) -> f (k a) (k b)</font></div><div><font face="monospace, monospace">with here of course f = (,), k = [] or List, and (i -> k i) = (:)</font></div></div>