3 ms·
a1369209993 was answering my "I don't think [natural transformations from the identity functor] always exist" with "no, they don't." The natural transformation
by kmill 7y ago
a1369209993 was answering my "I don't think [natural transformations from the identity functor] always exist" with "no, they don't."
The natural transformation would be a function "a -> Const q a" for all a. There can't be a way to do this for all q that is somehow natural in q, since this would have to construct a value of q to put into the Const constructor. Worse, (even though vanilla Haskell doesn't allow it), q might be the empty type, so there might be no functions "a -> Const q a" whatsoever. I think the point of the example is that keeping q polymorphic is a simulation of the empty type.
Allowing empty types, I'm happy with the example. However, this is technically a natural transformation in Haskell:
f :: a -> Const q a
f x = Const undefined x
since every type contains bottom (undefined).
- tel 7y agoAh, I misunderstood! And yes, absolutely. An even easier example data Nullity a This is a perfectly valid functor, too. Ignoring undefined, there are no values of it, but fmap cannot be used to create values of the mapped type, just manipulate them.