Here I am talking about the Functor category, which is defined as a category whose objects are functors and morphisms are natural transformations.
For reference: https://ncatlab.org/nlab/show/functor+category
I was wondering if it is possible to define this in Haskell.
If we define category like this:
class Category cat where
id :: cat a a
(.) :: cat b c -> cat a b -> cat a c
Now how do we define Functor
as an instance of this, given that Functor
is itself a typeclass?
EDIT
I am not tied to the above definition of a Category. I see Edward Kmett represents a Category
like this:
newtype Yoneda (p :: i -> i -> *) (a :: i) (b :: i) = Op { getOp :: p b a }
type family Op (p :: i -> i -> *) :: i -> i -> * where
Op (Yoneda p) = p
Op p = Yoneda p
class Vacuous (a :: i)
instance Vacuous a
class Category (p :: i -> i -> *) where
type Ob p :: i -> Constraint
type Ob p = Vacuous
id :: Ob p a => p a a
(.) :: p b c -> p a b -> p a c
I am not looking for Haskell specific implementation, but in any functional language in general.