
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. ?? -------------------------------------------------------

http://hackage.haskell.org/packages/archive/categories/0.59/doc/html/Control...
On Wed, Dec 12, 2012 at 3:54 PM, Gregory Guthrie
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Also,
http://hackage.haskell.org/packages/archive/bifunctors/3.0/doc/html/Data-Bif...
On Wed, Dec 12, 2012 at 4:12 PM, Clark Gaebel
http://hackage.haskell.org/packages/archive/categories/0.59/doc/html/Control...
On Wed, Dec 12, 2012 at 3:54 PM, Gregory Guthrie
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Yes, thanks, I've seen this; why can't cabal find the package? Is the fact that it is filed under "archive" an indicator?! I have tried Control.Bifunctor, and also Control.Categorical.Bifunctor, and Data.Bifunctor. Certainly it is an easy thing to define myself, but I'm both trying to be minimalistic, and to understand what failed. ------------------------------------------- From: Clark Gaebel [mailto:cgaebel@uwaterloo.ca] Sent: Wednesday, December 12, 2012 3:12 PM Subject: Re: [Haskell-cafe] Control.bimap? http://hackage.haskell.org/packages/archive/categories/0.59/doc/html/Control... . 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. ??

Control.Categorical.Bifunctor and Data.Bifunctor are the module names
not the packages.
The corresponding packages are "categories" and "bifunctors" respectively.
2012/12/12 Gregory Guthrie
Yes, thanks, I've seen this; why can't cabal find the package?
Is the fact that it is filed under "archive" an indicator?! I have tried Control.Bifunctor, and also Control.Categorical.Bifunctor, and Data.Bifunctor.
Certainly it is an easy thing to define myself, but I'm both trying to be minimalistic, and to understand what failed. ------------------------------------------- From: Clark Gaebel [mailto:cgaebel@uwaterloo.ca] Sent: Wednesday, December 12, 2012 3:12 PM Subject: Re: [Haskell-cafe] Control.bimap?
http://hackage.haskell.org/packages/archive/categories/0.59/doc/html/Control... . 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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Check out Control.Lens on hackage. On 13/12/12 07:54, Gregory Guthrie 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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Tony Morris http://tmorris.net/
participants (4)
-
Clark Gaebel
-
Gregory Guthrie
-
Timo von Holtz
-
Tony Morris