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


-- | A natural transformation package.
--   
--   A natural transformation transforms a container <tt>f a</tt> into
--   another container <tt>g a</tt>. Natural transformations act as functor
--   morphisms in category theory.
--   
--   The naming of <a>~&gt;</a>, <a>:~&gt;</a> and <a>$$</a> were taken,
--   with permission, from Edward Kmett's <tt>indexed</tt> 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

-- | A natural transformation from <tt>f</tt> to <tt>g</tt>.
type (~>) f g = forall x. f x -> g x

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

-- | <a>unwrapNT</a> is the nonfix version of <tt>#</tt>. It is used to
--   break natural transformation wrappers, including <a>:~&gt;</a>.
unwrapNT :: Transformation f g t => t -> (forall a. f a -> g a)

-- | A (natural) transformation is inside <tt>t</tt>, and contains
--   <tt>f</tt> and <tt>g</tt> (typically <a>Functor</a>s).
--   
--   The order of arguments allows the use of
--   <tt>GeneralizedNewtypeDeriving</tt> to wrap a <a>:~&gt;</a>, but
--   maintain the <a>Transformation</a> constraint. Thus, <tt>#</tt> 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
instance Control.Category.Category (Control.Natural.:~>)
instance forall k (f :: k -> *) (g :: k -> *). f ~ g => Data.Semigroup.Semigroup (f Control.Natural.:~> g)
instance forall k (f :: k -> *) (g :: k -> *). f ~ g => GHC.Base.Monoid (f Control.Natural.:~> g)
instance forall k (f :: k -> *) (g :: k -> *). Control.Natural.Transformation f g (f Control.Natural.:~> g)


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


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

-- | An <a>Object</a> is a natural transformation from a given
--   <a>Functor</a> <tt>f</tt>, to <a>IO</a>.
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
instance Control.Natural.Transformation f GHC.Types.IO (Control.Object.Object f)
