/usr/lib/hugs/packages/ALUT/Sound/ALUT/Errors.hs is in libhugs-alut-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 | -- #hide
--------------------------------------------------------------------------------
-- |
-- Module : Sound.ALUT.Errors
-- Copyright : (c) Sven Panne 2005
-- License : BSD-style (see the file libraries/ALUT/LICENSE)
--
-- Maintainer : sven.panne@aedion.de
-- Stability : provisional
-- Portability : portable
--
--------------------------------------------------------------------------------
module Sound.ALUT.Errors (
throwIfALfalse, throwIfNullPtr, makeBuffer
) where
import Control.Monad ( when )
import Data.Maybe ( fromJust, isNothing )
import Foreign.Ptr ( Ptr, nullPtr )
import Sound.OpenAL.AL.ALboolean ( unmarshalALboolean )
import Sound.OpenAL.AL.BasicTypes ( ALboolean, ALuint )
import Sound.OpenAL.AL.Buffer ( Buffer )
import Sound.OpenAL.AL.BufferInternal ( unmarshalBuffer )
import Sound.ALUT.Config ( alut_GetError, alut_GetErrorString )
--------------------------------------------------------------------------------
throwIf :: (a -> Bool) -> String -> IO a -> IO a
throwIf failurePredicate name action = do
returnValue <- action
when (failurePredicate returnValue) $ do
description <- alut_GetErrorString =<< alut_GetError
ioError (userError (name ++ ": " ++ description))
return returnValue
--------------------------------------------------------------------------------
throwIfALfalse :: String -> IO ALboolean -> IO ()
throwIfALfalse name action = do
throwIf (not . unmarshalALboolean) name action
return ()
--------------------------------------------------------------------------------
throwIfNullPtr :: String -> IO (Ptr a) -> IO (Ptr a)
throwIfNullPtr = throwIf (== nullPtr)
--------------------------------------------------------------------------------
makeBuffer :: String -> IO ALuint -> IO Buffer
makeBuffer name =
fmap fromJust . throwIf isNothing name . fmap unmarshalBuffer
|