File: Internal.hs

package info (click to toggle)
haskell-cairo 0.13.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 364 kB
  • sloc: haskell: 2,876; makefile: 47; ansic: 12
file content (70 lines) | stat: -rw-r--r-- 2,897 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{-# 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 { runRender :: ReaderT Cairo IO m }
  deriving (Functor, Applicative, Monad, MonadIO, MonadReader Cairo)

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