apecs-stm 0.1.2 → 0.1.3
raw patch · 3 files changed
+22/−9 lines, 3 filesdep ~apecsPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: apecs
API changes (from Hackage documentation)
- Apecs.STM: instance Apecs.Core.ExplGet GHC.Conc.Sync.STM (Apecs.STM.Map c)
- Apecs.STM: instance Apecs.Core.ExplGet GHC.Conc.Sync.STM (Apecs.STM.Unique c)
- Apecs.STM: instance Apecs.Core.ExplGet GHC.Types.IO (Apecs.STM.Map c)
- Apecs.STM: instance Apecs.Core.ExplGet GHC.Types.IO (Apecs.STM.Unique c)
+ Apecs.STM: instance Data.Typeable.Internal.Typeable c => Apecs.Core.ExplGet GHC.Conc.Sync.STM (Apecs.STM.Map c)
+ Apecs.STM: instance Data.Typeable.Internal.Typeable c => Apecs.Core.ExplGet GHC.Conc.Sync.STM (Apecs.STM.Unique c)
+ Apecs.STM: instance Data.Typeable.Internal.Typeable c => Apecs.Core.ExplGet GHC.Types.IO (Apecs.STM.Map c)
+ Apecs.STM: instance Data.Typeable.Internal.Typeable c => Apecs.Core.ExplGet GHC.Types.IO (Apecs.STM.Unique c)
- Apecs.STM.Prelude: ($~) :: (Get w m c, Set w m c) => Entity -> (c -> c) -> SystemT w m ()
+ Apecs.STM.Prelude: ($~) :: (Get w m cx, Set w m cy) => Entity -> (cx -> cy) -> SystemT w m ()
- Apecs.STM.Prelude: cmapM_ :: (Get w m c, Members w m c) => (c -> SystemT w m a) -> SystemT w m ()
+ Apecs.STM.Prelude: cmapM_ :: (Get w m c, Members w m c) => (c -> SystemT w m ()) -> SystemT w m ()
- Apecs.STM.Prelude: modify :: (Get w m c, Set w m c) => Entity -> (c -> c) -> SystemT w m ()
+ Apecs.STM.Prelude: modify :: (Get w m cx, Set w m cy) => Entity -> (cx -> cy) -> SystemT w m ()
Files
- CHANGELOG.md +4/−1
- apecs-stm.cabal +2/−2
- src/Apecs/STM.hs +16/−6
CHANGELOG.md view
@@ -1,4 +1,7 @@-## [Unreleased]+## [0.1.3]+### Changed+- (#60) Add `Component` type names in non-existent component errors+- Increased upper bound `apecs` dependency ## [0.1.2] ### Changed
apecs-stm.cabal view
@@ -1,5 +1,5 @@ name: apecs-stm-version: 0.1.2+version: 0.1.3 homepage: https://github.com/jonascarpay/apecs-stm#readme license: BSD3 license-file: LICENSE@@ -28,7 +28,7 @@ default-language: Haskell2010 build-depends:- apecs >= 0.7 && < 0.9,+ apecs >= 0.7 && < 0.10, base >= 4.9 && < 5, containers >= 0.5 && < 0.8, list-t >= 1 && < 1.2,
src/Apecs/STM.hs view
@@ -31,6 +31,7 @@ import Data.Maybe import Data.Monoid (Sum (..)) import Data.Semigroup+import Data.Typeable (Typeable, typeRep) import qualified Data.Vector.Unboxed as U import Language.Haskell.TH import qualified ListT as L@@ -46,13 +47,19 @@ instance ExplInit STM (Map c) where explInit = Map <$> M.new-instance ExplGet STM (Map c) where+instance Typeable c => ExplGet STM (Map c) where {-# INLINE explExists #-} {-# INLINE explGet #-} explExists (Map m) ety = isJust <$> M.lookup ety m explGet (Map m) ety = flip fmap (M.lookup ety m) $ \case Just c -> c- Nothing -> error $ "Reading non-existant STM Map component for entity " <> show ety+ notFound -> error $ unwords+ [ "Reading non-existent STM Map component"+ , show (typeRep notFound)+ , "for entity"+ , show ety+ ]+ instance ExplSet STM (Map c) where {-# INLINE explSet #-} explSet (Map m) ety x = M.insert x ety m@@ -66,7 +73,7 @@ instance ExplInit IO (Map c) where {-# INLINE explInit #-} explInit = S.atomically explInit-instance ExplGet IO (Map c) where+instance Typeable c => ExplGet IO (Map c) where {-# INLINE explExists #-} {-# INLINE explGet #-} explExists m e = S.atomically $ explExists m e@@ -86,11 +93,14 @@ instance ExplInit STM (Unique c) where explInit = Unique <$> newTVar Nothing -instance ExplGet STM (Unique c) where+instance Typeable c => ExplGet STM (Unique c) where {-# INLINE explGet #-} explGet (Unique ref) _ = flip fmap (readTVar ref) $ \case Just (_, c) -> c- Nothing -> error $ "Reading non-existant Unique component"+ notFound -> error $ unwords+ [ "Reading non-existent STM Unique component"+ , show (typeRep notFound)+ ] {-# INLINE explExists #-} explExists (Unique ref) ety = maybe False ((==ety) . fst) <$> readTVar ref @@ -112,7 +122,7 @@ instance ExplInit IO (Unique c) where {-# INLINE explInit #-} explInit = S.atomically explInit-instance ExplGet IO (Unique c) where+instance Typeable c => ExplGet IO (Unique c) where {-# INLINE explExists #-} explExists m e = S.atomically $ explExists m e {-# INLINE explGet #-}