OpenGL-2.8.0.0: A binding for the OpenGL graphics system

Portability | portable
Stability | stable
Maintainer | sven.panne@aedion.de
Safe Haskell | Safe-Inferred

Graphics.Rendering.OpenGL.GL.Exception

Description

This is a purely internal module to compensate for differences between Haskell implementations.

Synopsis

- bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c
- bracket_ :: IO a -> IO b -> IO c -> IO c
- unsafeBracket_ :: IO a -> IO b -> IO c -> IO c
- finallyRet :: IO a -> IO b -> IO (a, b)

# Documentation

bracket

Arguments

:: IO a | computation to run first ("acquire resource")
-> (a -> IO b) | computation to run last ("release resource")
-> (a -> IO c) | computation to run in-between
-> IO c |

When you want to acquire a resource, do some work with it, and then release the resource, it is a good idea to use `bracket`, because `bracket` will install the necessary exception handler to release the resource in the event that an exception is raised during the computation. If an exception is raised, then `bracket` will re-raise the exception (after performing the release).

A common example is opening a file:

     bracket
       (openFile "filename" ReadMode)
       (hClose)
       (\fileHandle -> do { ... })

The arguments to `bracket` are in this order so that we can partially apply it, e.g.:

     withFile name mode = bracket (openFile name mode) hClose

bracket_ :: IO a -> IO b -> IO c -> IO c

A variant of `bracket` where the return value from the first computation is not required.

unsafeBracket_ :: IO a -> IO b -> IO c -> IO cSource

finallyRet :: IO a -> IO b -> IO (a, b)Source