    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    {-# OPTIONS_HADDOCK hide #-}
    -----------------------------------------------------------------------------
    -- |
    -- Module      :  Graphics.Rendering.Cairo.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 Graphics.Rendering.Cairo.Internal (
        Render(..), bracketR
      , module Graphics.Rendering.Cairo.Types
      , module Graphics.Rendering.Cairo.Internal.Drawing.Cairo
      , module Graphics.Rendering.Cairo.Internal.Drawing.Paths
      , module Graphics.Rendering.Cairo.Internal.Drawing.Patterns
      , module Graphics.Rendering.Cairo.Internal.Drawing.Text
      , module Graphics.Rendering.Cairo.Internal.Drawing.Transformations
      , module Graphics.Rendering.Cairo.Internal.Fonts.FontOptions
      , module Graphics.Rendering.Cairo.Internal.Surfaces.Image
      , module Graphics.Rendering.Cairo.Internal.Surfaces.PDF
      , module Graphics.Rendering.Cairo.Internal.Surfaces.PNG
      , module Graphics.Rendering.Cairo.Internal.Surfaces.PS
      , module Graphics.Rendering.Cairo.Internal.Surfaces.SVG
      , module Graphics.Rendering.Cairo.Internal.Surfaces.Surface
      , module Graphics.Rendering.Cairo.Internal.Region
      , module Graphics.Rendering.Cairo.Internal.Utilities

      ) where

    import Graphics.Rendering.Cairo.Types
    import Graphics.Rendering.Cairo.Internal.Drawing.Cairo
    import Graphics.Rendering.Cairo.Internal.Drawing.Paths
    import Graphics.Rendering.Cairo.Internal.Drawing.Patterns
    import Graphics.Rendering.Cairo.Internal.Drawing.Text
    import Graphics.Rendering.Cairo.Internal.Drawing.Transformations
    import Graphics.Rendering.Cairo.Internal.Fonts.FontOptions
    import Graphics.Rendering.Cairo.Internal.Surfaces.Image
    import Graphics.Rendering.Cairo.Internal.Surfaces.PDF
    import Graphics.Rendering.Cairo.Internal.Surfaces.PNG
    import Graphics.Rendering.Cairo.Internal.Surfaces.PS
    import Graphics.Rendering.Cairo.Internal.Surfaces.SVG
    import Graphics.Rendering.Cairo.Internal.Surfaces.Surface
    import Graphics.Rendering.Cairo.Internal.Region
    import Graphics.Rendering.Cairo.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)