/usr/lib/hugs/packages/OpenGL/Graphics/Rendering/OpenGL/GL/StateVar.hs is in libhugs-opengl-bundled 98.200609.21-5.3ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | --------------------------------------------------------------------------------
-- |
-- Module : Graphics.Rendering.OpenGL.GL.StateVar
-- Copyright : (c) Sven Panne 2002-2005
-- License : BSD-style (see the file libraries/OpenGL/LICENSE)
--
-- Maintainer : sven.panne@aedion.de
-- Stability : provisional
-- Portability : portable
--
--------------------------------------------------------------------------------
module Graphics.Rendering.OpenGL.GL.StateVar (
HasGetter(..),
GettableStateVar, makeGettableStateVar,
HasSetter(..), set,
SettableStateVar, makeSettableStateVar,
StateVar, makeStateVar,
($~), ($=!), ($~!)
) where
import Data.IORef ( IORef, readIORef, writeIORef )
--------------------------------------------------------------------------------
infixr 2 $=
--------------------------------------------------------------------------------
class HasGetter g where
get :: g a -> IO a
--------------------------------------------------------------------------------
newtype GettableStateVar a = GettableStateVar (IO a)
instance HasGetter GettableStateVar where
get (GettableStateVar g) = g
makeGettableStateVar :: IO a -> GettableStateVar a
makeGettableStateVar = GettableStateVar
--------------------------------------------------------------------------------
class HasSetter s where
($=) :: s a -> a -> IO ()
{-# DEPRECATED set "use `sequence_' instead" #-}
set :: [IO ()] -> IO ()
set = sequence_
--------------------------------------------------------------------------------
newtype SettableStateVar a = SettableStateVar (a -> IO ())
instance HasSetter SettableStateVar where
($=) (SettableStateVar s) a = s a
-- | A strict variant of '$='.
($=!) :: HasSetter s => s a -> a -> IO ()
v $=! x = x `seq` v $= x
makeSettableStateVar :: (a -> IO ()) -> SettableStateVar a
makeSettableStateVar = SettableStateVar
--------------------------------------------------------------------------------
data StateVar a =
StateVar (GettableStateVar a) (SettableStateVar a)
instance HasGetter StateVar where
get (StateVar g _) = get g
instance HasSetter StateVar where
($=) (StateVar _ s) a = s $= a
makeStateVar :: IO a -> (a -> IO ()) -> StateVar a
makeStateVar g s = StateVar (makeGettableStateVar g) (makeSettableStateVar s)
--------------------------------------------------------------------------------
-- | A modificator convenience function.
($~) :: (HasGetter v, HasSetter v) => v a -> (a -> a) -> IO ()
v $~ f = do
x <- get v
v $= f x
-- | A strict variant of '$~'.
($~!) :: (HasGetter v, HasSetter v) => v a -> (a -> a) -> IO ()
v $~! f = do
x <- get v
v $=! f x
--------------------------------------------------------------------------------
instance HasGetter IORef where
get = readIORef
instance HasSetter IORef where
($=) = writeIORef
|