module Pandora.Pattern.Functor.Covariant where

import Pandora.Pattern.Semigroupoid (Semigroupoid)

infixl 4 -<$>-
infixl 3 -<<$$>-, -<$$>>-

{- |
> When providing a new instance, you should ensure it satisfies:
> * Identity morphism: (identity -<$>-) ≡ identity
> * Interpreted of morphisms: (f . g -<$>-) ≡ (f -<$>-) . (g -<$>-)
-}

class (Semigroupoid source, Semigroupoid target) => Covariant source target t where
	(-<$>-) :: source a b -> target (t a) (t b)
	
(-<$$>-) :: forall t u category a b 
	. (Covariant category category u, Covariant category category t) 
	=> category a b -> category (t (u a)) (t (u b))
-<$$>- :: category a b -> category (t (u a)) (t (u b))
(-<$$>-) category a b
s = (category (u a) (u b) -> category (t (u a)) (t (u b))
forall (source :: * -> * -> *) (target :: * -> * -> *)
       (t :: * -> *) a b.
Covariant source target t =>
source a b -> target (t a) (t b)
(-<$>-) (category a b -> category (u a) (u b)
forall (source :: * -> * -> *) (target :: * -> * -> *)
       (t :: * -> *) a b.
Covariant source target t =>
source a b -> target (t a) (t b)
(-<$>-) @category @category @u category a b
s))

(-<<$$>-) :: forall t u source target a b 
	. (Covariant source source u, Covariant source target t) 
	=> source a b -> target (t (u a)) (t (u b))
-<<$$>- :: source a b -> target (t (u a)) (t (u b))
(-<<$$>-) source a b
s = (source (u a) (u b) -> target (t (u a)) (t (u b))
forall (source :: * -> * -> *) (target :: * -> * -> *)
       (t :: * -> *) a b.
Covariant source target t =>
source a b -> target (t a) (t b)
(-<$>-) (source a b -> source (u a) (u b)
forall (source :: * -> * -> *) (target :: * -> * -> *)
       (t :: * -> *) a b.
Covariant source target t =>
source a b -> target (t a) (t b)
(-<$>-) @source @source @u source a b
s))

(-<$$>>-) :: forall source target t u a b 
	. (Covariant source target u, Covariant target target t) 
	=> source a b -> target (t (u a)) (t (u b))
-<$$>>- :: source a b -> target (t (u a)) (t (u b))
(-<$$>>-) source a b
s = (target (u a) (u b) -> target (t (u a)) (t (u b))
forall (source :: * -> * -> *) (target :: * -> * -> *)
       (t :: * -> *) a b.
Covariant source target t =>
source a b -> target (t a) (t b)
(-<$>-) (source a b -> target (u a) (u b)
forall (source :: * -> * -> *) (target :: * -> * -> *)
       (t :: * -> *) a b.
Covariant source target t =>
source a b -> target (t a) (t b)
(-<$>-) @source @target @u source a b
s))

-- TODO: Figure out how to work with hidden type variables
-- to put intermediate category `between`

(-<$$$>-) :: forall t u v category a b
	. (Covariant category category t, Covariant category category u, Covariant category category v) 
	=> category a b -> category (t (u (v a))) (t (u (v b)))
-<$$$>- :: category a b -> category (t (u (v a))) (t (u (v b)))
(-<$$$>-) category a b
s = (category (u (v a)) (u (v b))
-> category (t (u (v a))) (t (u (v b)))
forall (source :: * -> * -> *) (target :: * -> * -> *)
       (t :: * -> *) a b.
Covariant source target t =>
source a b -> target (t a) (t b)
(-<$>-) @category @category @t (category (v a) (v b) -> category (u (v a)) (u (v b))
forall (source :: * -> * -> *) (target :: * -> * -> *)
       (t :: * -> *) a b.
Covariant source target t =>
source a b -> target (t a) (t b)
(-<$>-) @category @category @u (category a b -> category (v a) (v b)
forall (source :: * -> * -> *) (target :: * -> * -> *)
       (t :: * -> *) a b.
Covariant source target t =>
source a b -> target (t a) (t b)
(-<$>-) @category @category @v category a b
s)))

(-<$$$$>-) :: forall category t u v w a b
	. (Covariant category category t, Covariant category category u, Covariant category category v, Covariant category category w) 
	=> category a b -> category (t (u (v (w a)))) (t (u (v (w b))))
-<$$$$>- :: category a b -> category (t (u (v (w a)))) (t (u (v (w b))))
(-<$$$$>-) category a b
s = (category (u (v (w a))) (u (v (w b)))
-> category (t (u (v (w a)))) (t (u (v (w b))))
forall (source :: * -> * -> *) (target :: * -> * -> *)
       (t :: * -> *) a b.
Covariant source target t =>
source a b -> target (t a) (t b)
(-<$>-) @category @category @t (category (v (w a)) (v (w b))
-> category (u (v (w a))) (u (v (w b)))
forall (source :: * -> * -> *) (target :: * -> * -> *)
       (t :: * -> *) a b.
Covariant source target t =>
source a b -> target (t a) (t b)
(-<$>-) @category @category @u (category (w a) (w b) -> category (v (w a)) (v (w b))
forall (source :: * -> * -> *) (target :: * -> * -> *)
       (t :: * -> *) a b.
Covariant source target t =>
source a b -> target (t a) (t b)
(-<$>-) @category @category @v (category a b -> category (w a) (w b)
forall (source :: * -> * -> *) (target :: * -> * -> *)
       (t :: * -> *) a b.
Covariant source target t =>
source a b -> target (t a) (t b)
(-<$>-) @category @category @w category a b
s))))