12 Dec 21:54 2012

## Control.bimap?

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.

??

-------------------------------------------------------

```_______________________________________________
```
12 Dec 22:12 2012

### Re: Control.bimap?

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.

??

-------------------------------------------------------

_______________________________________________

```_______________________________________________
```
12 Dec 22:13 2012

### Re: Control.bimap?

On Wed, Dec 12, 2012 at 4:12 PM, Clark Gaebel wrote:

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.

??

-------------------------------------------------------

_______________________________________________

```_______________________________________________
```
12 Dec 22:50 2012

### Re: Control.bimap?

```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 <at> uwaterloo.ca]
Sent: Wednesday, December 12, 2012 3:12 PM

.
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.
??
```
12 Dec 23:42 2012

### Re: Control.bimap?

```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 <guthrie <at> mum.edu>:
> 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 <at> uwaterloo.ca]
> Sent: Wednesday, December 12, 2012 3:12 PM
>
> .
>  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.
> ??
>
> _______________________________________________
```
13 Dec 01:55 2012

### Re: Control.bimap?

Check out Control.Lens on hackage.

On 13/12/12 07:54, Gregory Guthrie wrote:
<!-- /* Font Definitions */ <at> font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:purple; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal-compose; font-family:"Calibri","sans-serif"; color:windowtext;} .MsoChpDefault {mso-style-type:export-only; font-family:"Calibri","sans-serif";} <at> page WordSection1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;} div.WordSection1 {page:WordSection1;} -->

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.

??

-------------------------------------------------------

```_______________________________________________