StateVar 1.1.1.1 → 1.2.2
raw patch · 4 files changed
Files
- CHANGELOG.md +12/−0
- LICENSE +1/−1
- StateVar.cabal +14/−6
- src/Data/StateVar.hs +21/−1
CHANGELOG.md view
@@ -1,3 +1,15 @@+1.2.2+-----+* Relaxed upper version bound for `transformers`.++1.2.1+-----+* Explicitly mark `Data.StateVar` as Safe (or Trustworthy for GHC before 7.10).++1.2+---+* Added instances for `ForeignPtr`.+ 1.1.1.1 ------- * Relaxed upper version bound for `stm`.
LICENSE view
@@ -1,5 +1,5 @@ Copyright (c) 2014-2015, Edward Kmett-Copyright (c) 2009-2018, Sven Panne+Copyright (c) 2009-2021, Sven Panne All rights reserved. Redistribution and use in source and binary forms, with or without
StateVar.cabal view
@@ -1,12 +1,12 @@ name: StateVar-version: 1.1.1.1+version: 1.2.2 synopsis: State variables description: This package contains state variables, which are references in the IO monad, like IORefs or parts of the OpenGL state. homepage: https://github.com/haskell-opengl/StateVar bug-reports: https://github.com/haskell-opengl/StateVar/issues-copyright: Copyright (C) 2014-2015 Edward A. Kmett, 2009-2018 Sven Panne+copyright: Copyright (C) 2014-2015 Edward A. Kmett, 2009-2021 Sven Panne license: BSD3 license-file: LICENSE author: Sven Panne and Edward Kmett@@ -23,8 +23,11 @@ GHC == 8.0.2 GHC == 8.2.2 GHC == 8.4.3- GHC == 8.6.1- GHC == 8.7.*+ GHC == 8.6.5+ GHC == 8.8.4+ GHC == 8.10.3+ GHC == 8.10.4+ GHC == 9.0.1 cabal-version: >= 1.10 extra-source-files: README.md@@ -36,8 +39,8 @@ build-depends: base >= 4 && < 5,- stm >= 2.2.0.1 && < 2.6,- transformers >= 0.2 && < 0.6+ stm >= 2.3.0.1 && < 2.6,+ transformers >= 0.3 && < 0.7 default-language: Haskell2010 other-extensions:@@ -55,6 +58,11 @@ if impl(ghc>=7.4) -- other-extensions: DefaultSignatures cpp-options: -DUSE_DEFAULT_SIGNATURES=1++ if impl(ghc >= 9.0)+ -- these flags may abort compilation with GHC-8.10+ -- https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3295+ ghc-options: -Winferred-safe-imports -Wmissing-safe-haskell-mode source-repository head type: git
src/Data/StateVar.hs view
@@ -7,10 +7,16 @@ {-# LANGUAGE DefaultSignatures #-} #endif {-# LANGUAGE TypeFamilies #-}+-- Foreign.ForeignPtr is unsafe before GHC-7.10+#if __GLASGOW_HASKELL__ >= 704 && MIN_VERSION_base(4,8,0)+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE Trustworthy #-}+#endif -------------------------------------------------------------------------------- -- | -- Module : Data.StateVar--- Copyright : (c) Edward Kmett 2014-2015, Sven Panne 2009-2018+-- Copyright : (c) Edward Kmett 2014-2019, Sven Panne 2009-2021 -- License : BSD3 -- -- Maintainer : Sven Panne <svenpanne@gmail.com>@@ -81,6 +87,7 @@ import Control.Monad.IO.Class import Data.IORef import Data.Typeable+import Foreign.ForeignPtr import Foreign.Ptr import Foreign.Storable #if MIN_VERSION_base(4,12,0)@@ -195,6 +202,10 @@ p $= a = liftIO $ atomically $ writeTVar p a {-# INLINE ($=) #-} +instance Storable a => HasSetter (ForeignPtr a) a where+ p $= a = liftIO $ withForeignPtr p ($= a)+ {-# INLINE ($=) #-}+ -------------------------------------------------------------------- -- * HasUpdate --------------------------------------------------------------------@@ -252,6 +263,10 @@ a <- readTVar r writeTVar r $! f a +instance Storable a => HasUpdate (ForeignPtr a) a a where+ p $~ f = liftIO $ withForeignPtr p ($~ f)+ p $~! f = liftIO $ withForeignPtr p ($~! f)+ -------------------------------------------------------------------- -- * HasGetter --------------------------------------------------------------------@@ -283,3 +298,8 @@ instance HasGetter (IORef a) a where get = liftIO . readIORef {-# INLINE get #-}++instance Storable a => HasGetter (ForeignPtr a) a where+ get p = liftIO $ withForeignPtr p get+ {-# INLINE get #-}+