[Haskell-beginners] Type classes and synonyms

John Dorsey haskell at colquitt.org
Sat Nov 21 16:13:49 EST 2009


Chaddaï Fouché wrote:

> 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
> course).

Nonsense!  There are several perfectly good Haskell functions with that
type.  I count seven:

second :: (b -> c) -> (d, b) -> (d, c)
second = Control.Arrow.second
second = undefined
second = const undefined
second = const (const undefined)
second = const (const (undefined,undefined))
second f (d,b) = (undefined, f b)
second f (d,b) = (d, undefined)

Why I'm stickling on that point on the beginners list, however, is a
mystery.  I'll go write a more useful response, in contrition.

John



More information about the Beginners mailing list