    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    {-# OPTIONS_HADDOCK hide #-}
    -----------------------------------------------------------------------------
    -- |
    -- Module      :  GI.Cairo.Render.Internal
    -- Copyright   :  (c) Paolo Martini 2005
    -- License     :  BSD-style (see cairo/COPYRIGHT)
    --
    -- Maintainer  :  p.martini@neuralnoise.com
    -- Stability   :  experimental
    -- Portability :  portable
    --
    -- Direct bindings to the cairo library.
    -----------------------------------------------------------------------------
    -- #hide
    --
    module GI.Cairo.Render.Internal (
        Render(..), bracketR
      , module GI.Cairo.Render.Types
      , module GI.Cairo.Render.Internal.Drawing.Cairo
      , module GI.Cairo.Render.Internal.Drawing.Paths
      , module GI.Cairo.Render.Internal.Drawing.Patterns
      , module GI.Cairo.Render.Internal.Drawing.Text
      , module GI.Cairo.Render.Internal.Drawing.Transformations
      , module GI.Cairo.Render.Internal.Fonts.FontOptions
      , module GI.Cairo.Render.Internal.Surfaces.Image
      , module GI.Cairo.Render.Internal.Surfaces.PDF
      , module GI.Cairo.Render.Internal.Surfaces.PNG
      , module GI.Cairo.Render.Internal.Surfaces.PS
      , module GI.Cairo.Render.Internal.Surfaces.SVG
      , module GI.Cairo.Render.Internal.Surfaces.Surface
      , module GI.Cairo.Render.Internal.Region
      , module GI.Cairo.Render.Internal.Utilities

      ) where

    import GI.Cairo.Render.Types
    import GI.Cairo.Render.Internal.Drawing.Cairo
    import GI.Cairo.Render.Internal.Drawing.Paths
    import GI.Cairo.Render.Internal.Drawing.Patterns
    import GI.Cairo.Render.Internal.Drawing.Text
    import GI.Cairo.Render.Internal.Drawing.Transformations
    import GI.Cairo.Render.Internal.Fonts.FontOptions
    import GI.Cairo.Render.Internal.Surfaces.Image
    import GI.Cairo.Render.Internal.Surfaces.PDF
    import GI.Cairo.Render.Internal.Surfaces.PNG
    import GI.Cairo.Render.Internal.Surfaces.PS
    import GI.Cairo.Render.Internal.Surfaces.SVG
    import GI.Cairo.Render.Internal.Surfaces.Surface
    import GI.Cairo.Render.Internal.Region
    import GI.Cairo.Render.Internal.Utilities

    import Control.Monad.Reader
    import Control.Applicative
    import Control.Exception (bracket)

    -- | The Render monad. All drawing operations take place in a Render context.
    -- You can obtain a Render context for a 'Surface' using 'renderWith'.
    --
    newtype Render m = Render { forall m. Render m -> ReaderT Cairo IO m
    runRender :: ReaderT Cairo IO m }
      deriving ((forall a b. (a -> b) -> Render a -> Render b)
    -> (forall a b. a -> Render b -> Render a) -> Functor Render
    forall a b. a -> Render b -> Render a
    forall a b. (a -> b) -> Render a -> Render b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    $cfmap :: forall a b. (a -> b) -> Render a -> Render b
    fmap :: forall a b. (a -> b) -> Render a -> Render b
    $c<$ :: forall a b. a -> Render b -> Render a
    <$ :: forall a b. a -> Render b -> Render a
    Functor, Functor Render
    Functor Render =>
    (forall a. a -> Render a)
    -> (forall a b. Render (a -> b) -> Render a -> Render b)
    -> (forall a b c.
        (a -> b -> c) -> Render a -> Render b -> Render c)
    -> (forall a b. Render a -> Render b -> Render b)
    -> (forall a b. Render a -> Render b -> Render a)
    -> Applicative Render
    forall a. a -> Render a
    forall a b. Render a -> Render b -> Render a
    forall a b. Render a -> Render b -> Render b
    forall a b. Render (a -> b) -> Render a -> Render b
    forall a b c. (a -> b -> c) -> Render a -> Render b -> Render c
    forall (f :: * -> *).
    Functor f =>
    (forall a. a -> f a)
    -> (forall a b. f (a -> b) -> f a -> f b)
    -> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
    -> (forall a b. f a -> f b -> f b)
    -> (forall a b. f a -> f b -> f a)
    -> Applicative f
    $cpure :: forall a. a -> Render a
    pure :: forall a. a -> Render a
    $c<*> :: forall a b. Render (a -> b) -> Render a -> Render b
    <*> :: forall a b. Render (a -> b) -> Render a -> Render b
    $cliftA2 :: forall a b c. (a -> b -> c) -> Render a -> Render b -> Render c
    liftA2 :: forall a b c. (a -> b -> c) -> Render a -> Render b -> Render c
    $c*> :: forall a b. Render a -> Render b -> Render b
    *> :: forall a b. Render a -> Render b -> Render b
    $c<* :: forall a b. Render a -> Render b -> Render a
    <* :: forall a b. Render a -> Render b -> Render a
    Applicative, Applicative Render
    Applicative Render =>
    (forall a b. Render a -> (a -> Render b) -> Render b)
    -> (forall a b. Render a -> Render b -> Render b)
    -> (forall a. a -> Render a)
    -> Monad Render
    forall a. a -> Render a
    forall a b. Render a -> Render b -> Render b
    forall a b. Render a -> (a -> Render b) -> Render b
    forall (m :: * -> *).
    Applicative m =>
    (forall a b. m a -> (a -> m b) -> m b)
    -> (forall a b. m a -> m b -> m b)
    -> (forall a. a -> m a)
    -> Monad m
    $c>>= :: forall a b. Render a -> (a -> Render b) -> Render b
    >>= :: forall a b. Render a -> (a -> Render b) -> Render b
    $c>> :: forall a b. Render a -> Render b -> Render b
    >> :: forall a b. Render a -> Render b -> Render b
    $creturn :: forall a. a -> Render a
    return :: forall a. a -> Render a
    Monad, Monad Render
    Monad Render => (forall a. IO a -> Render a) -> MonadIO Render
    forall a. IO a -> Render a
    forall (m :: * -> *).
    Monad m =>
    (forall a. IO a -> m a) -> MonadIO m
    $cliftIO :: forall a. IO a -> Render a
    liftIO :: forall a. IO a -> Render a
    MonadIO, MonadReader Cairo)

    {-# INLINE bracketR #-}
    bracketR :: IO a -> (a -> IO b) -> (a -> Render c) -> Render c
    bracketR :: forall a b c. IO a -> (a -> IO b) -> (a -> Render c) -> Render c
    bracketR IO a
    begin a -> IO b
    end a -> Render c
    action =
      ReaderT Cairo IO c -> Render c
    forall m. ReaderT Cairo IO m -> Render m
    Render (ReaderT Cairo IO c -> Render c) -> ReaderT Cairo IO c -> Render c
    forall a b. (a -> b) -> a -> b
    $
      (Cairo -> IO c) -> ReaderT Cairo IO c
    forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
    ReaderT ((Cairo -> IO c) -> ReaderT Cairo IO c)
    -> (Cairo -> IO c) -> ReaderT Cairo IO c
    forall a b. (a -> b) -> a -> b
    $ \Cairo
    r ->
      IO a -> (a -> IO b) -> (a -> IO c) -> IO c
    forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
    bracket IO a
    begin a -> IO b
    end
              (\a
    s -> ReaderT Cairo IO c -> Cairo -> IO c
    forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
    runReaderT (Render c -> ReaderT Cairo IO c
    forall m. Render m -> ReaderT Cairo IO m
    runRender (Render c -> ReaderT Cairo IO c) -> Render c -> ReaderT Cairo IO c
    forall a b. (a -> b) -> a -> b
    $ a -> Render c
    action a
    s) Cairo
    r)