Re: [Haskell-cafe] Questions about the Functor class and it's use in "Data types à la carte"

Jonathan Cast jonathanccast at fastmail.fm
Sun Dec 16 05:29:35 EST 2007


On 16 Dec 2007, at 2:23 AM, Dominic Steinitz wrote:

>> keep in mind that Haskell "composition" (.)
>> is not really composition in the category-theoretic
>> sense, because it adds extra laziness. Use this
>
> Do you have a counter-example of (.) not being function composition in
> the categorical sense?

Let bot be the function defined by

bot :: alpha -> beta
bot = bot

By definition,

(.) = \ f -> \ g -> \ x -> f (g x)

Then

   bot . id
= ((\ f -> \ g -> \ x -> f (g x)) bot) id
= (\ g -> \ x -> bot (g x)) id
= \ x -> bot (g x)

which /= bot since (seq bot () = bot) but (seq (\ x -> M) () = ())  
regardless of what expression we substitute for M.

jcc



More information about the Haskell-Cafe mailing list