# 54 bytes

I honestly doubt that we'll beat @H.PWiz's 44 bytes solution, but nobody was using the fact that `(,)`

implements the type class `Functor`

, so here's another interesting one which isn't too bad:

```
((<*>snd).((,).).(.fst).(+).fst<*>).flip(fmap.(+).snd)
```

Try it online!

### Explanation

The implementation of the type class `Functor`

for *2*-Tuples are very similar to that of `Either`

(from *base-4.10.1.0*):

```
instance Functor ((,) a) where
fmap f (x,y) = (x, f y)
instance Functor (Either a) where
fmap _ (Left x) = Left x
fmap f (Right y) = Right (f y)
```

What this means for this challenge, is that the following function adds the second elements while keeping the first element of the second argument:

```
λ f = fmap.(+).snd :: Num a => (a, a) -> (a, a) -> (a, a)
λ f (1,-2) (3,-4)
(3,-6)
```

So if only we got some little helper `helpPlz = \a b -> (fst a+fst b,snd b)`

we could do `(helpPlz<*>).flip(fmap.(+).snd)`

and would be done. Luckily we have the tool `pointfree`

which gives us:

```
helpPlz = (`ap` snd) . ((,) .) . (. fst) . (+) . fst
```

So by simply plugging that function back in we arrive at the above solution (note that `(<*>) = ap`

which is in *base*).

9I never understood why it is called “point-

free” when it is actuallyfullof points. :P – Mr. Xcoder – 2017-12-29T17:10:19.1175

@Mr.Xcoder "A common misconception is that the 'points' of pointfree style are the (.) operator (function composition, as an ASCII symbol), which uses the same identifier as the decimal point. This is wrong. The term originated in topology, a branch of mathematics which works with spaces composed of points, and functions between those spaces. So a 'points-free' definition of a function is one which does not explicitly mention the points (values) of the space on which the function acts."

– Post Rock Garf Hunter – 2017-12-29T17:11:26.503What's considered an external library? Are imports from base allowed?

– Petr Pudlák – 2017-12-29T17:23:49.547I think so. So no keywords are allowed at all? I'd suggest explicitly allowing literal values like 0 and the empty tuple. Also, your example uses backticks, it should be clear then that's allowed. – xnor – 2017-12-29T17:41:12.953

@xnor Literals are allowed, keywords are not. Thanks for asking for clarifications, hopefully everything is clear. – Post Rock Garf Hunter – 2017-12-29T17:44:37.567

5

It's a shame we're not allowed to import the best Haskell package, or else the solution would just be

– Silvio Mayolo – 2017-12-30T03:05:00.243`(+)***(+)`

.2An idea:

`(+)<$>([1],2)<*>([3],4)`

gives`([1,3],6)`

. – xnor – 2017-12-30T05:40:02.7201

@SilvioMayolo Please add this to the tips for golfing in haskell! (and I invite you to join of monads and men :)

– flawr – 2017-12-30T10:29:56.1532

I spent some time trying to craft a fine solution utilizing xnor's tip... but I ended up with this garbage. I don't even know why I try sometimes...

– totallyhuman – 2017-12-30T13:59:07.917@flawr What is the meta consensus on using external packages? The package I referenced isn't part of

`base`

so it would have to be installed. – Silvio Mayolo – 2017-12-30T17:56:11.0231@SilvioMayolo You are allowed to use packages. If it's not in base its a different language, that's all. – Post Rock Garf Hunter – 2017-12-30T17:57:37.597

If not for the import ban, I'd say

`Biapplicative`

was the way to go. – dfeuer – 2019-06-14T22:35:58.317