Shortest a -> b -> (a -> b) function in Haskell I got the following question at a test:


  Write a function f with the following type a -&gt; b -&gt; (a -&gt; b). a and b should not be bound in any sense, the shorter the code, the better.


I came up with f a b = \x -&gt; snd ([a,x],b). Can you find something tinier?

Currently the winner is: f _=(.f).const
Your example can be shrunk by getting rid of the anonymous function on the right-hand side:

f a b x = snd ([a,x],b)


This works because the type a -&gt; b -&gt; a -&gt; b is equivalent to a -&gt; b -&gt; (a -&gt; b) in Haskell.