[Haskell-beginners] Type classes and synonyms

Chaddaï Fouché chaddai.fouche at gmail.com
Sat Nov 21 16:23:38 EST 2009


On Sat, Nov 21, 2009 at 10:13 PM, John Dorsey <haskell at colquitt.org> wrote:
> 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)

Right... Let's just say functions that may be evaluated to normal form
if their parameters can be evaluated to normal form.
Nitpicker !! :P

-- 
Jedaï


More information about the Beginners mailing list