TCache 0.10.0.10 → 0.10.0.11
raw patch · 4 files changed
+44/−20 lines, 4 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Data.Persistent.IDynamic: (!>) :: c -> String -> c
+ Data.Persistent.IDynamic: serializedEqual :: IDynamic -> ByteString -> Bool
Files
- Data/Persistent/IDynamic.hs +18/−13
- Data/TCache/IndexQuery.hs +13/−2
- Data/TCache/IndexText.hs +11/−3
- TCache.cabal +2/−2
Data/Persistent/IDynamic.hs view
@@ -36,15 +36,15 @@ import Data.RefSerialize import Data.HashTable as HT ---import Debug.Trace---(!>)= flip trace+import Debug.Trace+(!>)= flip trace data IDynamic = IDyn (IORef IDynType) deriving Typeable data IDynType= forall a w r.(Typeable a, Serialize a)- => DRight !a- | DLeft !(ByteString ,(Context, ByteString))+ => DRight !a+ | DLeft !(ByteString ,(Context, ByteString)) deriving Typeable@@ -115,19 +115,24 @@ toIDyn x= IDyn . unsafePerformIO . newIORef $ DRight x- - ++-- | check if a (possibly polimorphic) value within a IDynamic value has the given serialization"+serializedEqual (IDyn r) str= unsafePerformIO $ do+ t <- readIORef r+ case t of+ DRight x -> return $ runW (showp x) == str !> ("R "++ (show $ unpack $ runW (showp x)))+ DLeft (str', _) -> return $ str== str' !> ("L "++ (show $ unpack str' )) + fromIDyn :: (Typeable a , Serialize a)=> IDynamic -> a-fromIDyn x=r where- r = case safeFromIDyn x of- Left s -> error s +fromIDyn x= case safeFromIDyn x of+ Left s -> error s Right v -> v safeFromIDyn :: (Typeable a, Serialize a) => IDynamic -> Either String a safeFromIDyn (d@(IDyn r))= final where final= unsafePerformIO $ do- t<- readIORef r+ t <- readIORef r case t of DRight x -> return $ case cast x of Nothing -> Left $ "fromIDyn: unable to extract from "@@ -141,9 +146,9 @@ DLeft (str, c) -> handle (\(e :: SomeException) -> return $ Left (show e)) $ -- !> ("safeFromIDyn : "++ show e)) $ do- let v= runRC c rreadp str -- !> unpack str- writeIORef r $! DRight v -- !> ("***reified "++ unpack str)- return $! Right v -- !> ("*** end reified " ++ unpack str)+ let v= runRC c rreadp str -- !> unpack str+ writeIORef r $! DRight v -- !> ("***reified "++ unpack str)+ return $! Right v -- !> ("*** end reified " ++ unpack str)
Data/TCache/IndexQuery.hs view
@@ -73,7 +73,15 @@ {-# LANGUAGE DeriveDataTypeable, MultiParamTypeClasses , FunctionalDependencies, FlexibleInstances, UndecidableInstances , TypeSynonymInstances, IncoherentInstances #-}-module Data.TCache.IndexQuery(index, RelationOps(..), indexOf, recordsWith, (.&&.), (.||.), Select(..)) where+module Data.TCache.IndexQuery(+index+, RelationOps((.==.),(.<.),(.<=.),(.>=.),(.>.))+, indexOf+, recordsWith+, (.&&.)+, (.||.)+, Select(..))+where import Data.TCache import Data.TCache.Defs@@ -189,8 +197,11 @@ let [one, two]= typeRepArgs $! typeOf sel rindex= getDBRef $! keyIndex one two addTrigger $ selectorIndex sel rindex- withResources [] $ const [ (Index M.empty `asTypeOf` indexsel sel )]+ let proto= Index M.empty `asTypeOf` indexsel sel+ withResources [proto] $ init proto where+ init proto [Nothing] = [proto]+ init _ [Just _] = [] indexsel :: (reg-> a) -> Index reg a indexsel= undefined -- | implement the relational-like operators, operating on record fields
Data/TCache/IndexText.hs view
@@ -145,8 +145,11 @@ addTrigger (indext sel (words1 . convert)) let [t1,t2]= typeRepArgs $! typeOf sel t= show t1 ++ show t2- withResources [] $ const [IndexText t 0 M.empty M.empty M.empty]-+ let proto = IndexText t 0 M.empty M.empty M.empty+ withResources [proto] $ init proto+ where+ init proto [Nothing] = [proto]+ init _ [Just _] = [] -- | trigger the indexation of list fields with elements convertible to Text indexList :: (IResource a, Typeable a, Typeable b)@@ -157,7 +160,12 @@ addTrigger (indext sel convert) let [t1,t2]= typeRepArgs $! typeOf sel t= show t1 ++ show t2- withResources [] $ const [IndexText t 0 M.empty M.empty M.empty]+ let proto= IndexText t 0 M.empty M.empty M.empty+ withResources [proto] $ init proto++ where+ init proto [Nothing] = [proto]+ init _ [Just _]= []
TCache.cabal view
@@ -1,5 +1,5 @@ name: TCache-version: 0.10.0.10+version: 0.10.0.11 cabal-version: >= 1.6 build-type: Simple license: BSD3@@ -23,7 +23,7 @@ . In this release: .- error message in IndexQuery an IndexText queries when the data has not been indexed+ fixed reset of indexes when index, indexText or indexList is used