primitive-stablename (empty) → 0.1
raw patch · 5 files changed
+143/−0 lines, 5 filesdep +basedep +primitive
Dependencies added: base, primitive
Files
- CHANGELOG.md +12/−0
- LICENSE +29/−0
- README.md +6/−0
- primitive-stablename.cabal +56/−0
- src/Data/Primitive/StableName.hs +40/−0
+ CHANGELOG.md view
@@ -0,0 +1,12 @@+# Changelog++`primitive-stablename` uses [PVP Versioning][1].+The changelog is available [on GitHub][2].++0.0.0+=====++* Initially created.++[1]: https://pvp.haskell.org+[2]: https://github.com/chessai/primitive-stablename/releases
+ LICENSE view
@@ -0,0 +1,29 @@+BSD 3-Clause License++Copyright (c) 2019, chessai+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 copyright holder 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 HOLDER 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.md view
@@ -0,0 +1,6 @@+# primitive-stablename++[](https://hackage.haskell.org/package/primitive-stablename)+[](LICENSE)++primitive operations on StableNames
+ primitive-stablename.cabal view
@@ -0,0 +1,56 @@+cabal-version: 2.2+name:+ primitive-stablename+version:+ 0.1+synopsis:+ primitive operations on StableNames+description:+ Primitive operations on @'Data.Primitive.StableName'@s. This differs from the module+ 'System.Mem.StableName', in that it works in 'Control.Monad.ST.ST', 'IO', and any monad+ transformer stack built on top of either. It is recommended that users+ read the documentation of 'System.Mem.StableName' to learn more about+ the properties of @'Data.Primitive.StableName'@s.+homepage:+ https://github.com/chessai/primitive-stablename+bug-reports:+ https://github.com/chessai/primitive-stablename/issues+license:+ BSD-3-Clause+license-file:+ LICENSE+author:+ chessai+maintainer:+ chessai <chessai1996@gmail.com>+copyright:+ © 2019 chessai+category:+ Data+build-type:+ Simple+extra-doc-files:+ README.md+ , CHANGELOG.md+tested-with:+ GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.3++library+ hs-source-dirs:+ src+ exposed-modules:+ Data.Primitive.StableName+ build-depends:+ , base >= 4.10.1.0 && < 4.13+ , primitive >= 0.6.4 && < 0.8+ ghc-options:+ -Wall+ -O2+ default-language:+ Haskell2010++source-repository head+ type:+ git+ location:+ https://github.com/chessai/primitive-stablename.git
+ src/Data/Primitive/StableName.hs view
@@ -0,0 +1,40 @@+{-# language MagicHash #-}+{-# language UnboxedTuples #-}++{-| Primitive operations on 'StableName'. This differs from the module+ 'System.Mem.StableName', in that it works in 'Control.Monad.ST.ST', 'IO', and any monad+ transformer stack built on top of either. It is recommended that users+ read the documentation of 'System.Mem.StableName' to learn more about+ the properties of 'StableName's.+-}++module Data.Primitive.StableName+ ( StableName(..)+ , makeStableName+ , eqStableName+ ) where++import GHC.Exts (StableName#,isTrue#,eqStableName#,makeStableName#,unsafeCoerce#)+import Control.Monad.Primitive (PrimMonad(PrimState,primitive))++-- | An abstract name for an object. This supports tests for equality,+-- but not hashing.+data StableName s a = StableName (StableName# a)++instance Eq (StableName s a) where+ (==) = eqStableName+ {-# inline (==) #-}++-- | Make a 'StableName' for an arbitrary object. The object is not+-- evaluated.+makeStableName :: PrimMonad m => a -> m (StableName (PrimState m) a)+makeStableName a = primitive $ \s ->+ case makeStableName# a (unsafeCoerce# s) of+ (# s', sn #) -> (# unsafeCoerce# s', StableName sn #)+{-# inline makeStableName #-}++-- | Equality on 'StableName' that does not require that the types of+-- the arguments match.+eqStableName :: StableName s a -> StableName s b -> Bool+eqStableName (StableName sn1) (StableName sn2) = isTrue# (eqStableName# sn1 sn2)+{-# inline eqStableName #-}