acid-state 0.16.0.1 → 0.16.1
raw patch · 5 files changed
+66/−13 lines, 5 filesdep ~basedep ~criteriondep ~template-haskellnew-uploaderPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base, criterion, template-haskell
API changes (from Hackage documentation)
+ Data.Acid.TemplateHaskell: type TyVarBndrUnit = TyVarBndr
- Data.Acid.TemplateHaskell: TypeAnalysis :: [TyVarBndr] -> Cxt -> [Type] -> Type -> Type -> Bool -> TypeAnalysis
+ Data.Acid.TemplateHaskell: TypeAnalysis :: [TyVarBndrUnit] -> Cxt -> [Type] -> Type -> Type -> Bool -> TypeAnalysis
- Data.Acid.TemplateHaskell: [tyvars] :: TypeAnalysis -> [TyVarBndr]
+ Data.Acid.TemplateHaskell: [tyvars] :: TypeAnalysis -> [TyVarBndrUnit]
- Data.Acid.TemplateHaskell: eventCxts :: Type -> [TyVarBndr] -> Name -> Type -> [Pred]
+ Data.Acid.TemplateHaskell: eventCxts :: Type -> [TyVarBndrUnit] -> Name -> Type -> [Pred]
- Data.Acid.TemplateHaskell: makeAcidic' :: SerialiserSpec -> [Name] -> Name -> [TyVarBndr] -> [Con] -> Q [Dec]
+ Data.Acid.TemplateHaskell: makeAcidic' :: SerialiserSpec -> [Name] -> Name -> [TyVarBndrUnit] -> [Con] -> Q [Dec]
- Data.Acid.TemplateHaskell: makeIsAcidic :: () => SerialiserSpec -> [Name] -> Name -> [TyVarBndr] -> p -> Q Dec
+ Data.Acid.TemplateHaskell: makeIsAcidic :: SerialiserSpec -> [Name] -> Name -> [TyVarBndr] -> p -> Q Dec
Files
- CHANGELOG.md +24/−0
- acid-state.cabal +2/−2
- src/Data/Acid/Abstract.hs +2/−2
- src/Data/Acid/TemplateHaskell.hs +32/−8
- test/Data/Acid/TemplateHaskellSpec.hs +6/−1
CHANGELOG.md view
@@ -1,3 +1,27 @@+0.16.1+======++ - Support GHC-9.0.2, template-haskell 2.18++0.16.0+======++ - support network-3.x and ghc-8.8.1+ - Fix tests+ ([#131](https://github.com/acid-state/acid-state/pull/131))+ - Haddock documentation fixes+ - Update build dependency constraints++0.15.2+======++ - adds acid-state-repair recovery tool+ ([#126](https://github.com/acid-state/acid-state/pull/16))+ - parameterize the underlying serialization library+ ([#96](https://github.com/acid-state/acid-state/pull/96))+ - support safecopy-0.10, which supports GHC.Generics+ ([#128](https://github.com/acid-state/acid-state/pull/128))+ 0.15.0 ======
acid-state.cabal view
@@ -1,5 +1,5 @@ Name: acid-state-Version: 0.16.0.1+Version: 0.16.1 Synopsis: Add ACID guarantees to any serializable Haskell data structure. Description: Use regular Haskell data structures as your database and get stronger ACID guarantees than most RDBMS offer. Homepage: https://github.com/acid-state/acid-state@@ -57,7 +57,7 @@ mtl, network < 3.2, network-bsd,- template-haskell < 2.17,+ template-haskell < 2.19, th-expand-syns if os(windows)
src/Data/Acid/Abstract.hs view
@@ -83,7 +83,7 @@ -- scheduleUpdate acid EventB -- @ scheduleUpdate :: UpdateEvent event => AcidState (EventState event) -> event -> IO (MVar (EventResult event))-scheduleUpdate = _scheduleUpdate -- Redirection to make Haddock happy.+scheduleUpdate acid = _scheduleUpdate acid -- Redirection to make Haddock happy. -- | Schedule multiple Update events and wait for them to be durable, but -- throw away their results. This is useful for importing existing@@ -110,7 +110,7 @@ -- | Issue a Query event and wait for its result. Events may be issued in parallel. query :: QueryEvent event => AcidState (EventState event) -> event -> IO (EventResult event)-query = _query -- Redirection to make Haddock happy.+query acid = _query acid -- Redirection to make Haddock happy. -- | Same as 'query' but lifted into any monad capable of doing IO. query' :: (QueryEvent event, MonadIO m) => AcidState (EventState event) -> event -> m (EventResult event)
src/Data/Acid/TemplateHaskell.hs view
@@ -20,6 +20,10 @@ import Control.Monad.State (MonadState) import Control.Monad.Reader (MonadReader) +#if !MIN_VERSION_template_haskell(2,17,0)+type TyVarBndrUnit = TyVarBndr+#endif+ {-| Create the control structures required for acid states using Template Haskell. @@ -97,7 +101,7 @@ _ -> error "Data.Acid.TemplateHaskell: Unsupported state type. Only 'data', 'newtype' and 'type' are supported." _ -> error "Data.Acid.TemplateHaskell: Given state is not a type." -makeAcidic' :: SerialiserSpec -> [Name] -> Name -> [TyVarBndr] -> [Con] -> Q [Dec]+makeAcidic' :: SerialiserSpec -> [Name] -> Name -> [TyVarBndrUnit] -> [Con] -> Q [Dec] makeAcidic' ss eventNames stateName tyvars constructors = do events <- sequence [ makeEvent ss eventName | eventName <- eventNames ] acidic <- makeIsAcidic ss eventNames stateName tyvars constructors@@ -197,11 +201,11 @@ -- -- In this case we have to rename 'x' to the actual state we're going to -- use. This is done by 'renameState'.-eventCxts :: Type -- ^ State type- -> [TyVarBndr] -- ^ type variables that will be used for the State type in the IsAcidic instance- -> Name -- ^ 'Name' of the event- -> Type -- ^ 'Type' of the event- -> [Pred] -- ^ extra context to add to 'IsAcidic' instance+eventCxts :: Type -- ^ State type+ -> [TyVarBndrUnit] -- ^ type variables that will be used for the State type in the IsAcidic instance+ -> Name -- ^ 'Name' of the event+ -> Type -- ^ 'Type' of the event+ -> [Pred] -- ^ extra context to add to 'IsAcidic' instance eventCxts targetStateType targetTyVars eventName eventType = let TypeAnalysis { context = cxt, stateType } = analyseType eventName eventType@@ -227,8 +231,15 @@ rename pred table t@(ForallT tyvarbndrs cxt typ) = -- this is probably wrong? I don't think acid-state can really handle this type anyway.. ForallT (map renameTyVar tyvarbndrs) (map (unify table) cxt) (rename pred table typ) where+#if MIN_VERSION_template_haskell(2,17,0)+ renameTyVar :: TyVarBndr a -> TyVarBndr a+ renameTyVar (PlainTV name ann) = PlainTV (renameName pred table name) ann+ renameTyVar (KindedTV name k ann) = KindedTV (renameName pred table name) k ann+#else+ renameTyVar :: TyVarBndr -> TyVarBndr renameTyVar (PlainTV name) = PlainTV (renameName pred table name) renameTyVar (KindedTV name k) = KindedTV (renameName pred table name) k+#endif rename pred table (VarT n) = VarT $ renameName pred table n rename pred table (AppT a b) = AppT (rename pred table a) (rename pred table b) rename pred table (SigT a k) = SigT (rename pred table a) k@@ -400,7 +411,7 @@ eventStructName = toStructName eventName data TypeAnalysis = TypeAnalysis- { tyvars :: [TyVarBndr]+ { tyvars :: [TyVarBndrUnit] , context :: Cxt , argumentTypes :: [Type] , stateType :: Type@@ -455,7 +466,11 @@ } -- (...) => a go tyvars cxt args (ForallT tyvars2 cxt2 a)- = go (tyvars ++ tyvars2) (cxt ++ cxt2) args a+#if MIN_VERSION_template_haskell(2,17,0)+ = go (tyvars ++ fmap void tyvars2) (cxt ++ cxt2) args a+#else+ = go (tyvars ++ tyvars2) (cxt ++ cxt2) args a+#endif -- (MonadState state m) => ... -> m result -- (MonadReader state m) => ... -> m result go tyvars' cxt argumentTypes (AppT (VarT m) resultType)@@ -489,12 +504,21 @@ findTyVars _ = [] -- | extract the 'Name' from a 'TyVarBndr'+#if MIN_VERSION_template_haskell(2,17,0)+tyVarBndrName :: TyVarBndr a -> Name+tyVarBndrName (PlainTV n _) = n+tyVarBndrName (KindedTV n _ _) = n++allTyVarBndrNames :: [TyVarBndr a] -> [Name]+allTyVarBndrNames tyvars = map tyVarBndrName tyvars+#else tyVarBndrName :: TyVarBndr -> Name tyVarBndrName (PlainTV n) = n tyVarBndrName (KindedTV n _) = n allTyVarBndrNames :: [TyVarBndr] -> [Name] allTyVarBndrNames tyvars = map tyVarBndrName tyvars+#endif -- | Convert the 'Name' of the event function into the name of the -- corresponding data constructor.
test/Data/Acid/TemplateHaskellSpec.hs view
@@ -144,7 +144,12 @@ let x = mkName "x" it "accepts constrained type variables in the state" $ do- let binders = [PlainTV (mkName "x")]+ let binders :: [TyVarBndrUnit]+#if MIN_VERSION_template_haskell(2,17,0)+ binders = [PlainTV (mkName "x") ()]+#else+ binders = [PlainTV (mkName "x")]+#endif stateType = ConT ''Maybe `AppT` VarT x eventType <- runQ [t| forall a. (Ord a) => Int -> Query (Maybe a) Int|]