ObjectName-1.1.0.1/0000755000000000000000000000000012636205221012044 5ustar0000000000000000ObjectName-1.1.0.1/Setup.hs0000644000000000000000000000005612636205221013501 0ustar0000000000000000import Distribution.Simple main = defaultMain ObjectName-1.1.0.1/LICENSE0000644000000000000000000000271512636205221013056 0ustar0000000000000000Copyright (c) 2014, Sven Panne All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ObjectName-1.1.0.1/README.md0000644000000000000000000000033412636205221013323 0ustar0000000000000000[![Hackage](https://img.shields.io/hackage/v/ObjectName.svg)](https://hackage.haskell.org/package/ObjectName) [![Build Status](https://travis-ci.org/svenpanne/ObjectName.png)](https://travis-ci.org/svenpanne/ObjectName) ObjectName-1.1.0.1/ObjectName.cabal0000644000000000000000000000172012636205221015037 0ustar0000000000000000name: ObjectName version: 1.1.0.1 synopsis: Explicitly handled object names description: This tiny package contains the class ObjectName, which corresponds to the general notion of explicitly handled identifiers for API objects, e.g. a texture object name in OpenGL or a buffer object name in OpenAL. homepage: https://github.com/svenpanne/ObjectName bug-reports: https://github.com/svenpanne/ObjectName/issues copyright: Copyright (C) 2014-2015 Sven Panne license: BSD3 license-file: LICENSE author: Sven Panne maintainer: Sven Panne category: Data build-type: Simple cabal-version: >=1.10 extra-source-files: README.md library exposed-modules: Data.ObjectName build-depends: base >= 4 && < 5, transformers >= 0.2 && < 0.6 default-language: Haskell2010 other-extensions: CPP hs-Source-Dirs: src ghc-options: -Wall source-repository head type: git location: https://github.com/haskell-opengl/ObjectName.git ObjectName-1.1.0.1/src/0000755000000000000000000000000012636205221012633 5ustar0000000000000000ObjectName-1.1.0.1/src/Data/0000755000000000000000000000000012636205221013504 5ustar0000000000000000ObjectName-1.1.0.1/src/Data/ObjectName.hs0000644000000000000000000000533112636205221016051 0ustar0000000000000000{-# LANGUAGE CPP #-} -------------------------------------------------------------------------------- -- | -- Module : Data.ObjectName -- Copyright : (c) Sven Panne 2015 -- License : BSD3 -- -- Maintainer : Sven Panne -- Stability : stable -- Portability : portable -- -- Object names are explicitly handled identifiers for API objects, e.g. a -- texture object name in OpenGL or a buffer object name in OpenAL. They come in -- two flavors: If a name can exist on its own without an associated object, we -- have a 'GeneratableObjectName', otherwise we have an 'ObjectName'. -- -------------------------------------------------------------------------------- module Data.ObjectName ( ObjectName(..), GeneratableObjectName(..) ) where import Control.Monad ( replicateM ) import Control.Monad.IO.Class ( MonadIO(..) ) -------------------------------------------------------------------------------- -- | An 'ObjectName' is an explicitly handled identifier for API objects, e.g. a -- texture object name in OpenGL or a buffer object name in OpenAL. #if __GLASGOW_HASKELL__ < 708 -- -- Minimal complete definition: 'isObjectName' plus one of 'deleteObjectName' or -- 'deleteObjectNames'. #endif class ObjectName a where #if __GLASGOW_HASKELL__ >= 708 {-# MINIMAL isObjectName, ( deleteObjectName | deleteObjectNames ) #-} #endif -- | Test if the given object name is currently in use, i.e. test if it has -- been generated, but not been deleted so far. isObjectName :: MonadIO m => a -> m Bool -- | Make the given object name available again, declaring it as unused. deleteObjectName :: MonadIO m => a -> m () deleteObjectName = deleteObjectNames . (:[]) -- | Bulk version of 'deleteObjectName'. deleteObjectNames:: MonadIO m => [a] -> m () deleteObjectNames = mapM_ deleteObjectName -- | A 'GeneratableObjectName' is an 'ObjectName' which can be generated without -- creating an associated object at the same time, e.g. an OpenGL buffer object -- name. Note that e.g. OpenGL program object names do not fall into this -- category, because you can only create such a name together with a program -- object itself. #if __GLASGOW_HASKELL__ < 708 -- -- Minimal complete definition: One of 'genObjectName' or 'genObjectNames'. #endif class ObjectName a => GeneratableObjectName a where #if __GLASGOW_HASKELL__ >= 708 {-# MINIMAL genObjectName | genObjectNames #-} #endif -- | Generate a new unused object name. By generating the name, it becomes -- used. genObjectName :: MonadIO m => m a genObjectName = liftIO . fmap head . genObjectNames $ 1 -- | Bulk version of 'genObjectName'. genObjectNames :: MonadIO m => Int -> m [a] genObjectNames = flip replicateM genObjectName