module Pandora.Pattern.Functor.Adjoint (Adjoint (..), type (-|)) where
import Pandora.Core.Functor (type (:.), type (:=))
import Pandora.Pattern.Category (identity)
import Pandora.Pattern.Functor.Covariant (Covariant)
type (-|) = Adjoint
infixl 4 -|, |-
class (Covariant t, Covariant u) => Adjoint t u where
{-# MINIMAL (-|), (|-) #-}
(-|) :: a -> (t a -> b) -> u b
(|-) :: t a -> (a -> u b) -> b
phi :: (t a -> b) -> a -> u b
phi f x = x -| f
psi :: (a -> u b) -> t a -> b
psi g x = x |- g
eta :: a -> u :. t := a
eta = phi identity
epsilon :: t :. u := a -> a
epsilon = psi identity