packages feed

unique 0.0.1 → 0.0.2

raw patch · 7 files changed

+158/−155 lines, 7 filesdep ~basedep ~hashablesetup-changednew-uploader

Dependency ranges changed: base, hashable

Files

CHANGELOG.markdown view
@@ -1,8 +1,13 @@-## 0.0.1--* GHC-9.0 compatibility-* Mark `Control.Concurrent.Unique` as `Trustworthy`--## 0--* Repository initialized+## 0.0.2
+
+* Allow building with `hashable-1.5.*`.
+* Drop support for pre-8.0 versions of GHC.
+
+## 0.0.1
+
+* GHC-9.0 compatibility
+* Mark `Control.Concurrent.Unique` as `Trustworthy`
+
+## 0
+
+* Repository initialized
LICENSE view
@@ -1,26 +1,26 @@-Copyright 2015 Edward Kmett--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.--THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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 2015 Edward Kmett
+
+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.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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.
README.markdown view
@@ -1,16 +1,16 @@-unique-==============--[![Hackage](https://img.shields.io/hackage/v/unique.svg)](https://hackage.haskell.org/package/unique) [![Build Status](https://github.com/ekmett/unique/workflows/Haskell-CI/badge.svg)](https://github.com/ekmett/unique/actions?query=workflow%3AHaskell-CI)---This package provides a version of Data.Unique that is fully concurrent.--Contact Information----------------------Contributions and bug reports are welcome!--Please feel free to contact me through github or on the #haskell IRC channel on irc.freenode.net.---Edward Kmett+unique
+==============
+
+[![Hackage](https://img.shields.io/hackage/v/unique.svg)](https://hackage.haskell.org/package/unique) [![Build Status](https://github.com/ekmett/unique/workflows/Haskell-CI/badge.svg)](https://github.com/ekmett/unique/actions?query=workflow%3AHaskell-CI)
+
+
+This package provides a version of Data.Unique that is fully concurrent.
+
+Contact Information
+-------------------
+
+Contributions and bug reports are welcome!
+
+Please feel free to contact me through github or on the #haskell IRC channel on irc.freenode.net.
+
+-Edward Kmett
Setup.hs view
@@ -1,2 +1,2 @@-import Distribution.Simple-main = defaultMain+import Distribution.Simple
+main = defaultMain
src/Control/Concurrent/Unique.hs view
@@ -1,61 +1,56 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE UnboxedTuples #-}-{-# LANGUAGE MagicHash #-}-{-# LANGUAGE Trustworthy #-}---- | An abstract interface to a concurrent unique symbol generator.------ Unlike @Data.Unique@ from @base@ the values are not a member of 'Ord'. However, there is no global bottleneck.-module Control.Concurrent.Unique-  ( Unique, newUnique-  ) where--import Data.Hashable (Hashable (..))-import GHC.IO-import GHC.Exts---- $setup--- >>> import Data.Hashable---- | Unique identifiers are created by creating heap objects in kind # that--- can be compared for value equality and then hashing them using their initial allocation--- address.------ >>> x <- newUnique--- >>> y <- newUnique--- >>> z <- newUnique------ >>> [x == x, y == y, z == z]--- [True,True,True]------ >>> [x == y, y == z, z == x]--- [False,False,False]------ The hashes could be same, in theory, but in practice they are different--- as well.------ >>> [ hash x == hash x, hash y == hash y, hash z == hash z]--- [True,True,True]------ >>> [ hash x == hash y, hash y == hash z, hash z == hash x]--- [False,False,False]---- TODO: If, due to a small heap size we find we have high collision rate on initial allocation location--- we might consider upgrading this initial hash with something fast and volatile, e.g. rdtsc-data Unique = Unique !Int (MutableByteArray# RealWorld)--instance Eq Unique where-#if MIN_VERSION_base(4,7,0)-  Unique _ p == Unique _ q = isTrue# (sameMutableByteArray# p q)-#else-  Unique _ p == Unique _ q = sameMutableByteArray# p q-#endif--instance Hashable Unique where-  hash (Unique i _) = i-  hashWithSalt d (Unique i _) = hashWithSalt d i---- | Allocate a new 'Unique' value. The value returned will not compare equal to any other value of type 'Unique' returned by previous calls to 'newUnique'. There is no limit on the number of times 'newUnique' may be called.-newUnique :: IO Unique-newUnique = IO $ \s -> case newByteArray# 0# s of-  (# s', ba #) -> (# s', Unique (I# (addr2Int# (unsafeCoerce# ba))) ba #)+{-# LANGUAGE UnboxedTuples #-}
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE Trustworthy #-}
+
+-- | An abstract interface to a concurrent unique symbol generator.
+--
+-- Unlike @Data.Unique@ from @base@ the values are not a member of 'Ord'. However, there is no global bottleneck.
+module Control.Concurrent.Unique
+  ( Unique, newUnique
+  ) where
+
+import Data.Hashable (Hashable (..))
+import GHC.IO
+import GHC.Exts
+
+-- $setup
+-- >>> import Data.Hashable
+
+-- | Unique identifiers are created by creating heap objects in kind # that
+-- can be compared for value equality and then hashing them using their initial allocation
+-- address.
+--
+-- >>> x <- newUnique
+-- >>> y <- newUnique
+-- >>> z <- newUnique
+--
+-- >>> [x == x, y == y, z == z]
+-- [True,True,True]
+--
+-- >>> [x == y, y == z, z == x]
+-- [False,False,False]
+--
+-- The hashes could be same, in theory, but in practice they are different
+-- as well.
+--
+-- >>> [ hash x == hash x, hash y == hash y, hash z == hash z]
+-- [True,True,True]
+--
+-- >>> [ hash x == hash y, hash y == hash z, hash z == hash x]
+-- [False,False,False]
+
+-- TODO: If, due to a small heap size we find we have high collision rate on initial allocation location
+-- we might consider upgrading this initial hash with something fast and volatile, e.g. rdtsc
+data Unique = Unique !Int (MutableByteArray# RealWorld)
+
+instance Eq Unique where
+  Unique _ p == Unique _ q = isTrue# (sameMutableByteArray# p q)
+
+instance Hashable Unique where
+  hash (Unique i _) = i
+  hashWithSalt d (Unique i _) = hashWithSalt d i
+
+-- | Allocate a new 'Unique' value. The value returned will not compare equal to any other value of type 'Unique' returned by previous calls to 'newUnique'. There is no limit on the number of times 'newUnique' may be called.
+newUnique :: IO Unique
+newUnique = IO $ \s -> case newByteArray# 0# s of
+  (# s', ba #) -> (# s', Unique (I# (addr2Int# (unsafeCoerce# ba))) ba #)
stack.yaml view
@@ -1,1 +1,1 @@-resolver: nightly-2015-09-27+resolver: nightly-2015-09-27
unique.cabal view
@@ -1,41 +1,44 @@-name:          unique-category:      Concurrency, Data-version:       0.0.1-license:       BSD3-cabal-version: >= 1.10-license-file:  LICENSE-author:        Edward A. Kmett-maintainer:    Edward A. Kmett <ekmett@gmail.com>-stability:     experimental-homepage:      http://github.com/ekmett/unique/-bug-reports:   http://github.com/ekmett/unique/issues-copyright:     Copyright (C) 2015 Edward A. Kmett-synopsis:      Fully concurrent unique identifiers-description:   Fully concurrent unique identifiers.-build-type:    Simple-extra-source-files: CHANGELOG.markdown README.markdown stack.yaml--tested-with:   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.3--source-repository head-  type: git-  location: git://github.com/ekmett/unique.git--library-  default-language: Haskell2010-  hs-source-dirs: src-  other-extensions: CPP, MagicHash, UnboxedTuples-  exposed-modules: Control.Concurrent.Unique-  ghc-options: -Wall-  build-depends:-    base     >= 4.5 && < 5,-    hashable >= 1.1 && < 1.4+name:          unique
+category:      Concurrency, Data
+version:       0.0.2
+license:       BSD3
+cabal-version: >= 1.10
+license-file:  LICENSE
+author:        Edward A. Kmett
+maintainer:    Edward A. Kmett <ekmett@gmail.com>
+stability:     experimental
+homepage:      http://github.com/ekmett/unique/
+bug-reports:   http://github.com/ekmett/unique/issues
+copyright:     Copyright (C) 2015 Edward A. Kmett
+synopsis:      Fully concurrent unique identifiers
+description:   Fully concurrent unique identifiers.
+build-type:    Simple
+extra-source-files: CHANGELOG.markdown README.markdown stack.yaml
+
+tested-with:   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.2
+             , GHC == 9.2.8
+             , GHC == 9.4.8
+             , GHC == 9.6.7
+             , GHC == 9.8.4
+             , GHC == 9.10.2
+             , GHC == 9.12.2
+
+source-repository head
+  type: git
+  location: https://github.com/ekmett/unique.git
+
+library
+  default-language: Haskell2010
+  hs-source-dirs: src
+  other-extensions: CPP, MagicHash, UnboxedTuples
+  exposed-modules: Control.Concurrent.Unique
+  ghc-options: -Wall
+  build-depends:
+    base     >= 4.9 && < 5,
+    hashable >= 1.1 && < 1.6