[Haskell-beginners] Type classes and synonyms

Chaddaï Fouché chaddai.fouche at gmail.com
Sat Nov 21 15:51:06 EST 2009

On Sat, Nov 21, 2009 at 9:33 PM, Philip Scott
<haskell-beginners at foo.me.uk> wrote:
> For the other newbies, 'second' takes a function and a tuple, it applies the
> function to the second thing in your tuple and returns a tuple with the first
> value unchanged, and the result of applying 'f' to the second:

That's what it does on a specific arrow, though generally that's the idea.

> What I am struggling to understand is what on earth the type signature means:
> :t second
> second :: (Arrow a) => a b c -> a (d, b) (d, c)
> How can (\x -> "fish") be an 'a b c' when it really looks like this:
> :t (\x->"fish")
> (\x->"fish") :: t -> [Char]

Right, but you must understand that (->) is a type constructor, just
like Maybe or Either or your Ts. It takes two types parameter and
return a function type. So "a -> b" is the infix syntax, but you could
write that "(->) a b" just like you can write "3 + 5" as "(+) 3 5".
Once you've done that on your function you get "(->) t Char" which
looks a bit more like "a b c"...
The final piece is that (->) is an Arrow, the most basic one but still
an Arrow, so if you replace a by (->) in the type of second, you get :
second :: (->) b c -> (->) (d, b) (d, c)
which is just
second :: (b -> c) -> (d, b) -> (d, c)
which corresponds exactly to the action of second you described
(that's the only function that could have this type, except bottom of


More information about the Beginners mailing list