Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where's the functor in the natural transformation?

I've had this question on the very back of my mind ever since I saw the definition of natural transformations in the Edward Kmett's old category-extras package:

-- | A natural transformation between functors f and g.
type f :~> g = forall a. f a -> g a

But now reading Stephen Diehl's blog post on adjunctions, I find this:

A natural transformation in our context will be a polymorphic function associated with two Haskell functor instances f and g with type signature (Functor f, Functor g) => forall a. f a -> g a. Which could be written with the following type synonym.

type Nat f g = forall a. f a -> g a

Which was a slap in the face of my "I'll continue ignoring this" attitude. So for the question: Why is okay to suddenly drop the functor constraints?

like image 976
user2141650 Avatar asked Feb 18 '14 00:02

user2141650


1 Answers

It is not allowed in Haskell to put a constraint on a type synonym. And even for datatypes, it has been deprecated in Haskell 2010. Instead, the constraint should be put on the functions that operate on values of this type.

like image 163
Tarmil Avatar answered Nov 10 '22 16:11

Tarmil