Re: [Haskell-cafe] Questions about the Functor class and it's use in "Data types à la carte"
Roberto Zunino
zunino at di.unipi.it
Mon Dec 17 07:18:27 EST 2007
Dominic Steinitz wrote:
> Roberto Zunino wrote:
>>This is the point: eta does not hold if seq exists.
>>
>> undefined `seq` 1 == undefined
>> (\x -> undefined x) `seq` 1 == 1
>
> Ok I've never used seq and I've never used unsavePerformIO. Provided my
> program doesn't contain these then can I assume that eta reduction holds
> and that (.) is categorical composition?
Yes, provided that you do not use seq and all its related stuff, e.g.
($!), foldl', bang patterns, data Foo a = Foo !a, ...
Also, note that you still can define and use seq restricted to many
useful types:
seqInt :: Int -> a -> a
seqInt 0 x = x
seqInt _ x = x
IIRC, you can also have a quite general
seqData :: Data a => a -> b -> b
>>The "(.) does not form a category" argument should be something like:
>>
>> id . undefined == (\x -> id (undefined x)) /= undefined
>>
>>where the last inequation is due to the presence of seq. That is,
>>without seq, there is no way to distinguish between undefined and (const
>>undefined), so you could use a semantic domain where they coincide. In
>>that case, eta does hold.
>
> It would be a pretty odd semantic domain where 1 == undefined. Or
> perhaps, I should say not a very useful one.
in the new domain, you do not have 1 == undefined (which are still
different) but merely
undefined == (\x -> undefined)
Regards,
Zun.
More information about the Haskell-Cafe
mailing list