ObjectName 1.0.1.1 → 1.1.0.0
raw patch · 5 files changed
+138/−130 lines, 5 filesdep +transformersdep ~basesetup-changedPVP ok
version bump matches the API change (PVP)
Dependencies added: transformers
Dependency ranges changed: base
API changes (from Hackage documentation)
- Data.ObjectName: class ObjectName a => GeneratableObjectName a where genObjectName = fmap head $ genObjectNames 1 genObjectNames = flip replicateM genObjectName
+ Data.ObjectName: class ObjectName a => GeneratableObjectName a where genObjectName = liftIO . fmap head . genObjectNames $ 1 genObjectNames = flip replicateM genObjectName
- Data.ObjectName: deleteObjectName :: ObjectName a => a -> IO ()
+ Data.ObjectName: deleteObjectName :: (ObjectName a, MonadIO m) => a -> m ()
- Data.ObjectName: deleteObjectNames :: ObjectName a => [a] -> IO ()
+ Data.ObjectName: deleteObjectNames :: (ObjectName a, MonadIO m) => [a] -> m ()
- Data.ObjectName: genObjectName :: GeneratableObjectName a => IO a
+ Data.ObjectName: genObjectName :: (GeneratableObjectName a, MonadIO m) => m a
- Data.ObjectName: genObjectNames :: GeneratableObjectName a => Int -> IO [a]
+ Data.ObjectName: genObjectNames :: (GeneratableObjectName a, MonadIO m) => Int -> m [a]
- Data.ObjectName: isObjectName :: ObjectName a => a -> IO Bool
+ Data.ObjectName: isObjectName :: (ObjectName a, MonadIO m) => a -> m Bool
Files
- LICENSE +28/−28
- ObjectName.cabal +34/−28
- README.md +1/−0
- Setup.hs +2/−2
- src/Data/ObjectName.hs +73/−72
LICENSE view
@@ -1,28 +1,28 @@-Copyright (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.+Copyright (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.cabal view
@@ -1,28 +1,34 @@-name: ObjectName-version: 1.0.1.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-license: BSD3-license-file: LICENSE-author: Sven Panne-maintainer: Sven Panne <svenpanne@gmail.com>-category: Data-build-type: Simple-cabal-version: >=1.10--library- exposed-modules: Data.ObjectName- build-depends: base >= 3 && < 5- 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+name: ObjectName +version: 1.1.0.0 +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 <svenpanne@gmail.com> +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.5 + 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
+ README.md view
@@ -0,0 +1,1 @@+[](https://hackage.haskell.org/package/ObjectName) [](https://travis-ci.org/svenpanne/ObjectName)
Setup.hs view
@@ -1,2 +1,2 @@-import Distribution.Simple-main = defaultMain+import Distribution.Simple +main = defaultMain
src/Data/ObjectName.hs view
@@ -1,72 +1,73 @@-{-# LANGUAGE CPP #-}------------------------------------------------------------------------------------ |--- Module : Data.ObjectName--- Copyright : (c) Sven Panne 2014--- License : BSD3--- --- Maintainer : Sven Panne <svenpanne@gmail.com>--- 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 )-------------------------------------------------------------------------------------- | 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 :: a -> IO Bool-- -- | Make the given object name available again, declaring it as unused.- deleteObjectName :: a -> IO ()- deleteObjectName = deleteObjectNames . (:[])-- -- | Bulk version of 'deleteObjectName'.- deleteObjectNames:: [a] -> IO ()- 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 :: IO a- genObjectName = fmap head $ genObjectNames 1-- -- | Bulk version of 'genObjectName'.- genObjectNames :: Int -> IO [a]- genObjectNames = flip replicateM genObjectName+{-# LANGUAGE CPP #-} +-------------------------------------------------------------------------------- +-- | +-- Module : Data.ObjectName +-- Copyright : (c) Sven Panne 2015 +-- License : BSD3 +-- +-- Maintainer : Sven Panne <svenpanne@gmail.com> +-- 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