ObjectName-1.1.0.2/src/0000755000000000000000000000000013463560127012644 5ustar0000000000000000ObjectName-1.1.0.2/src/Data/0000755000000000000000000000000013463560127013515 5ustar0000000000000000ObjectName-1.1.0.2/src/Data/ObjectName.hs0000644000000000000000000000533613463560127016067 0ustar0000000000000000{-# LANGUAGE CPP #-} -------------------------------------------------------------------------------- -- | -- Module : Data.ObjectName -- Copyright : (c) Sven Panne 2014-2018 -- 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 ObjectName-1.1.0.2/README.md0000644000000000000000000000043614144007642013332 0ustar0000000000000000[![Hackage](https://img.shields.io/hackage/v/ObjectName.svg)](https://hackage.haskell.org/package/ObjectName) [![Build Status](https://github.com/svenpanne/ObjectName/actions/workflows/haskell-ci.yml/badge.svg)](https://github.com/svenpanne/ObjectName/actions/workflows/haskell-ci.yml) ObjectName-1.1.0.2/LICENSE0000644000000000000000000000272213463560127013065 0ustar0000000000000000Copyright (c) 2014-2018, 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.2/Setup.hs0000644000000000000000000000005613463560127013512 0ustar0000000000000000import Distribution.Simple main = defaultMain ObjectName-1.1.0.2/ObjectName.cabal0000644000000000000000000000233714144007642015050 0ustar0000000000000000name: ObjectName version: 1.1.0.2 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-2018 Sven Panne license: BSD3 license-file: LICENSE author: Sven Panne maintainer: Sven Panne category: Data build-type: Simple tested-with: GHC == 7.0.4 GHC == 7.2.2 GHC == 7.4.2 GHC == 7.6.3 GHC == 7.8.4 GHC == 7.10.3 GHC == 8.0.2 GHC == 8.2.2 GHC == 8.4.4 GHC == 8.6.5 GHC == 8.8.4 GHC == 8.10.7 GHC == 9.0.1 GHC == 9.2.1 cabal-version: >= 1.10 extra-source-files: README.md library exposed-modules: Data.ObjectName build-depends: base >= 4 && < 5, transformers >= 0.2 && < 0.7 default-language: Haskell2010 other-extensions: CPP hs-Source-Dirs: src ghc-options: -Wall if impl(ghc > 8) ghc-options: -Wcompat source-repository head type: git location: https://github.com/haskell-opengl/ObjectName.git