-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | A natural transformation package.
--   
--   A natural transformation transforms a container f a into
--   another container g a. Natural transformations act as functor
--   morphisms in category theory.
--   
--   The naming of ~>, :~> and $$ were taken,
--   with permission, from Edward Kmett's indexed package.
@package natural-transformation
@version 0.4

-- | A data type and class for natural transformations.
module Control.Natural

-- | A natural transformation suitable for storing in a container.
newtype f :~> g
NT :: (f ~> g) -> (:~>) f g
[$$] :: (:~>) f g -> f ~> g
infixr 0 :~>
infixr 0 $$

-- | A natural transformation from f to g.
type f ~> g = forall x. f x -> g x
infixr 0 ~>

-- | wrapNT builds our natural transformation abstraction out of a
--   natural transformation function.
--   
--   An alias to NT provided for symmetry with unwrapNT.
wrapNT :: (forall a. f a -> g a) -> f :~> g

-- | unwrapNT is the nonfix version of #. It is used to
--   break natural transformation wrappers, including :~>.
unwrapNT :: Transformation f g t => t -> forall a. f a -> g a

-- | A (natural) transformation is inside t, and contains
--   f and g (typically Functors).
--   
--   The order of arguments allows the use of
--   GeneralizedNewtypeDeriving to wrap a :~>, but
--   maintain the Transformation constraint. Thus, # can be
--   used on abstract data types.
class Transformation f g t | t -> f g

-- | The invocation method for a natural transformation.
(#) :: Transformation f g t => t -> forall a. f a -> g a
infix 0 #
instance forall k (f :: k -> *) (g :: k -> *). Control.Natural.Transformation f g (f Control.Natural.:~> g)
instance Control.Category.Category (Control.Natural.:~>)
instance forall k (f :: k -> *) (g :: k -> *). (f GHC.Types.~ g) => GHC.Base.Semigroup (f Control.Natural.:~> g)
instance forall k (f :: k -> *) (g :: k -> *). (f GHC.Types.~ g) => GHC.Base.Monoid (f Control.Natural.:~> g)

-- | 
GHC RULE for Natural Transformation
--   
--   
--   RULES "natural free theorem" [~]
--      forall h (r :: (Functor f, Functor g, Transformation f g t) => t) .
--        fmap h . (r #) = (r #) . fmap h
--   
module Control.Natural.RULES

-- | An Object type, which is a natural transformation into the IO
--   monad.
module Control.Object

-- | An Object is a natural transformation from a given
--   Functor f, to IO.
newtype Object f
Object :: (f ~> IO) -> Object f

-- | The invocation method for a natural transformation.
(#) :: Transformation f g t => t -> forall a. f a -> g a
infix 0 #
instance Control.Natural.Transformation f GHC.Types.IO (Control.Object.Object f)
