[Haskell-cafe] Control.bimap?
Clark Gaebel
cgaebel at uwaterloo.ca
Wed Dec 12 22:13:33 CET 2012
Also,
http://hackage.haskell.org/packages/archive/bifunctors/3.0/doc/html/Data-Bifunctor.html
On Wed, Dec 12, 2012 at 4:12 PM, Clark Gaebel <cgaebel at uwaterloo.ca> wrote:
>
> http://hackage.haskell.org/packages/archive/categories/0.59/doc/html/Control-Categorical-Bifunctor.html
>
>
> On Wed, Dec 12, 2012 at 3:54 PM, Gregory Guthrie <guthrie at mum.edu> wrote:
>
>> I found a nice idiom for a graph algorithm where the pairs of nodes
>> representing links could be merged into node lists by something like:****
>>
>> ns = nub $ map fst g --head nodes****
>>
>> ne = nub $ map snd g -- tail nodes****
>>
>> ** **
>>
>> And found a nicer approach:****
>>
>> (ns,ne) = (nub***nub) unzip g****
>>
>> Or perhaps:****
>>
>> (ns.ne) = bimap nub nub $ unzip g -- from Control.Bifunctor ****
>>
>> ** **
>>
>> The SO reference I saw described bimap as a way to map a function over a
>> pair, and it seemed like a great match, but I cannot find the bimap
>> function, and cabal reports no package Control.Bifunctor.****
>>
>> ??****
>>
>> -------------------------------------------------------****
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121212/4f0ed947/attachment.htm>
More information about the Haskell-Cafe
mailing list