From 88a4a4a765e50cf758b58ab7aee8721efc1d4c6f Mon Sep 17 00:00:00 2001 From: Harri Nieminen Date: Sun, 2 Apr 2023 16:34:12 +0300 Subject: [PATCH] fix typos --- Data/Persistent/Collection.hs | 4 ++-- Data/Persistent/IDynamic.hs | 2 +- Data/TCache.hs | 34 +++++++++++++++++----------------- Data/TCache/Defs.hs | 2 +- Data/TCache/IResource.hs | 10 +++++----- Data/TCache/IndexQuery.hs | 6 +++--- Data/TCache/IndexText.hs | 2 +- Data/TCache/Memoization.hs | 2 +- Data/TCache/Triggers.hs | 4 ++-- demos/DBRef.hs | 4 ++-- demos/caching.hs | 4 ++-- demos/triggerRelational.lhs | 2 +- 12 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Data/Persistent/Collection.hs b/Data/Persistent/Collection.hs index 76e0a1f..50011ce 100644 --- a/Data/Persistent/Collection.hs +++ b/Data/Persistent/Collection.hs @@ -17,7 +17,7 @@ data.persistent collection aƱadiendo elementos node Node (refQueue a) implementar un query language by key - by attribute (addAttibute) + by attribute (addAttribute) by class xpath implementar un btree sobre el @@ -102,7 +102,7 @@ isEmptySTM queue= do --- | Get the reference to new or existing queue trough its name +-- | Get the reference to new or existing queue through its name getQRef :: (Typeable a, Serialize a) => String -> RefQueue a getQRef n = getDBRef . key $ Queue n undefined undefined diff --git a/Data/Persistent/IDynamic.hs b/Data/Persistent/IDynamic.hs index a6e9f0c..745decb 100644 --- a/Data/Persistent/IDynamic.hs +++ b/Data/Persistent/IDynamic.hs @@ -43,7 +43,7 @@ tosave d@(IDyn r)= unsafePerformIO $ do instance Serialize Save where showp (Save s)= insertString s - readp = error "readp not impremented for Save" + readp = error "readp not implemented for Save" errorfied :: String -> String -> a diff --git a/Data/TCache.hs b/Data/TCache.hs index 355fd6c..17fc810 100644 --- a/Data/TCache.hs +++ b/Data/TCache.hs @@ -48,7 +48,7 @@ with read/write primitives, so the traditional syntax of Haskell STM references can be used for interfacing with databases. As expected, the DBRefs are transactional, because they operate in the STM monad. -A @DBRef@ is associated with its referred object trough its key. +A @DBRef@ is associated with its referred object through its key. Since DBRefs are serializable, they can be elements of mutable cached objects themselves. They could point to other mutable objects and so on, so DBRefs can act as \"hardwired\" relations from mutable objects @@ -136,7 +136,7 @@ DBRefs and @*Resource(s)@ primitives are completely interoperable. The latter op -- * @IResource@ class {- | Cached objects must be instances of `IResource`. -Such instances can be implicitly derived trough auxiliary classes for file persistence. +Such instances can be implicitly derived through auxiliary classes for file persistence. -} ,IResource(..) @@ -179,9 +179,9 @@ user `buy` item= 'withResources'[user,item] buyIt ,deleteResource -- * Trigger operations -{- | Trriggers are called just before an object of the given type is created, modified or deleted. +{- | Triggers are called just before an object of the given type is created, modified or deleted. The DBRef to the object and the new value is passed to the trigger. -The called trigger function has two parameters: the DBRef being accesed +The called trigger function has two parameters: the DBRef being accessed (which still contains the old value), and the new value. If the content of the DBRef is being deleted, the second parameter is 'Nothing'. if the DBRef contains Nothing, then the object is being created @@ -238,7 +238,7 @@ in the cache. The usual thing is that you do not have it, and the element will b collected (but still there will be a NotRead entry for this key!!!). If the DBRef is read again, the TCache will go to permanent storage to retrieve it. -clear opertions such `clearsyncCache` does something similar: it does not delete the +clear operations such `clearsyncCache` does something similar: it does not delete the element from the cache. It just inform the garbage collector that there is no longer necessary to maintain the element in the cache. So if the element has no other references (maybe you keep a variable that point to that DBRef) it will be GCollected. @@ -320,12 +320,12 @@ import Control.Exception(catch, handle, throw, evaluate, bracket, SomeException) -- there are two references to the DBRef here -- The Maybe one keeps it alive until the cache releases it for *Resources -- calls which does not reference dbrefs explicitly --- The weak reference keeps the dbref alive until is it not referenced elsewere +-- The weak reference keeps the dbref alive until is it not referenced elsewhere data CacheElem= forall a.(IResource a,Typeable a) => CacheElem (Maybe (DBRef a)) (Weak(DBRef a)) type Ht = H.BasicHashTable String CacheElem --- contains the hastable, last sync time +-- contains the hashtable, last sync time type Cache = IORef (Ht , Integer) data CheckTPVarFlags= AddToHash | NoAddToHash @@ -354,7 +354,7 @@ numElems= do return $ length elems --- | Retuns some statistical information for the DBRefs in the cache (for debugging) +-- | Returns some statistical information for the DBRefs in the cache (for debugging) -- This returns a tuple containing: -- total : count of the total elements in cache -- dirty : the elements which need to be written to the persistent storage @@ -826,7 +826,7 @@ releaseTPVar cache r =do applyTriggers [dbref] [Just r] writeTVar tvr . Exist $ Elem r ti ti w <- unsafeIOToSTM . mkWeakPtr dbref $ Just $ fixToCache dbref - unsafeIOToSTM $ H.insert cache keyr (CacheElem (Just dbref) w)-- accesed and modified XXX + unsafeIOToSTM $ H.insert cache keyr (CacheElem (Just dbref) w)-- accessed and modified XXX return () @@ -862,9 +862,9 @@ updateListToHash hash kv= mapM (update1 hash) kv where -- | Start the thread that periodically call `clearSyncCache` to clean and writes on the persistent storage. -- it is indirectly set by means of `syncWrite`, since it is more higuer level. I recommend to use the latter -- Otherwise, 'syncCache' or `clearSyncCache` or `atomicallySync` must be invoked explicitly or no persistence will exist. --- Cache writes allways save a coherent state +-- Cache writes always save a coherent state clearSyncCacheProc :: - Int -- ^ number of seconds betwen checks. objects not written to disk are written + Int -- ^ number of seconds between checks. objects not written to disk are written -> (Integer -> Integer-> Integer-> Bool) -- ^ The user-defined check-for-cleanup-from-cache for each object. 'defaultCheck' is an example -> Int -- ^ The max number of objects in the cache, if more, the cleanup starts -> IO ThreadId -- ^ Identifier of the thread created @@ -883,7 +883,7 @@ criticalSection mv f= bracket $ const f -- | Force the atomic write of all cached objects modified since the last save into permanent storage. --- Cache writes allways save a coherent state. As always, only the modified objects are written. +-- Cache writes always save a coherent state. As always, only the modified objects are written. syncCache :: IO () syncCache = criticalSection saving $ do (cache,lastSync) <- readIORef refcache --`debug` "syncCache" @@ -941,7 +941,7 @@ atomicallySync proc=do -- |Saves the unsaved elems of the cache. --- Cache writes allways save a coherent state. +-- Cache writes always save a coherent state. -- Unlike `syncCache` this call deletes some elems from the cache when the number of elems > @sizeObjects@. -- The deletion depends on the check criteria, expressed by the first parameter. -- 'defaultCheck' is the one implemented to be passed by default. Look at it to understand the clearing criteria. @@ -961,7 +961,7 @@ clearSyncCache check1 sizeObjects= criticalSection saving $ do -- delete elems from the cache according with the checking criteria filtercache t cache lastSync = mapM_ filter1 where - filter1 (CacheElem Nothing _)= return() --alive because the dbref is being referenced elsewere + filter1 (CacheElem Nothing _)= return() --alive because the dbref is being referenced elsewhere filter1 (CacheElem (Just (DBRef key1 _)) w) = do mr <- deRefWeak w case mr of @@ -978,15 +978,15 @@ clearSyncCache check1 sizeObjects= criticalSection saving $ do -- | This is a default cache clearance check. It forces to drop from the cache all the --- elems not accesed since half the time between now and the last sync +-- elems not accessed since half the time between now and the last sync -- if it returns True, the object will be discarded from the cache -- it is invoked when the cache size exceeds the number of objects configured -- in 'clearSyncCacheProc' or 'clearSyncCache' defaultCheck :: Integer -- ^ current time in seconds -> Integer -- ^ last access time for a given object - -> Integer -- ^ last cache synchronization (with the persisten storage) - -> Bool -- ^ return true for all the elems not accesed since half the time between now and the last sync + -> Integer -- ^ last cache synchronization (with the persistent storage) + -> Bool -- ^ return true for all the elems not accessed since half the time between now and the last sync defaultCheck now lastAccess lastSync | lastAccess > halftime = False | otherwise = True diff --git a/Data/TCache/Defs.hs b/Data/TCache/Defs.hs index 3873e01..9fb6700 100644 --- a/Data/TCache/Defs.hs +++ b/Data/TCache/Defs.hs @@ -58,7 +58,7 @@ Example: data Car= Car{owner :: DBRef Person , cname:: String} deriving (Show, Read, Eq, Typeable) @ -Since Person and Car are instances of 'Read' ans 'Show', by defining the 'Indexable' instance +Since Person and Car are instances of 'Read' and 'Show', by defining the 'Indexable' instance will implicitly define the IResource instance for file persistence: @ diff --git a/Data/TCache/IResource.hs b/Data/TCache/IResource.hs index 03d4453..cceab26 100644 --- a/Data/TCache/IResource.hs +++ b/Data/TCache/IResource.hs @@ -7,14 +7,14 @@ module Data.TCache.IResource where -} class IResource a where {- The `keyResource string must be a unique since this is used to index it in the hash table. - when accessing a resource, the user must provide a partial object for wich the key can be obtained. + when accessing a resource, the user must provide a partial object for which the key can be obtained. for example: @data Person= Person{name, surname:: String, account :: Int ....) keyResource Person n s ...= n++s@ - the data being accesed must define the fields used by keyResource. For example + the data being accessed must define the fields used by keyResource. For example @ readResource Person {name="John", surname= "Adams"}@ @@ -27,8 +27,8 @@ class IResource a where {- | Implements the database access and marshalling of the object. while the database access must be strict, the marshaling must be lazy if, as is often the case, - some parts of the object are not really accesed. - If the object contains DBRefs, this avoids unnecesary cache lookups. + some parts of the object are not really accessed. + If the object contains DBRefs, this avoids unnecessary cache lookups. This method is called within 'atomically' blocks. Since STM transactions retry, readResourceByKey may be called twice in strange situations. So it must be idempotent, not only in the result but also in the effect in the database . However, because it is executed by 'safeIOToSTM' it is guaranteed that the execution is not interrupted. @@ -60,7 +60,7 @@ class IResource a where writeResources :: [a] -> IO() writeResources= mapM_ writeResource - -- | Delete the resource. It is called syncronously. So it must commit + -- | Delete the resource. It is called synchronously. So it must commit delResource:: a-> IO() delResource x= delResources [x] diff --git a/Data/TCache/IndexQuery.hs b/Data/TCache/IndexQuery.hs index b018eab..8e7e217 100644 --- a/Data/TCache/IndexQuery.hs +++ b/Data/TCache/IndexQuery.hs @@ -17,7 +17,7 @@ it includes - a 'recordsWith' clause to extract entire registers -An example that register the owner and name fields fo the Car register and the +An example that register the owner and name fields of the Car register and the name of the Person register, create the Bruce register, return the Bruce DBRef, create two Car registers with bruce as owner and query for the registers with bruce as owner and its name alpabeticaly higuer than \"Bat mobile\" @@ -234,7 +234,7 @@ class RelationOps field1 field2 res | field1 field2 -> res where (.<=.) :: field1 -> field2 -> STM res (.<.) :: field1 -> field2 -> STM res --- Instance of relations betweeen fields and values +-- Instance of relations between fields and values -- field .op. value instance (Queriable reg a) => RelationOps (reg -> a) a [DBRef reg] where (.==.) field value= do @@ -261,7 +261,7 @@ join op field1 field2 =do type JoinData reg reg'=[([DBRef reg],[DBRef reg'])] --- Instance of relations betweeen fields +-- Instance of relations between fields -- field1 .op. field2 instance (Queriable reg a ,Queriable reg' a ) =>RelationOps (reg -> a) (reg' -> a) (JoinData reg reg') where diff --git a/Data/TCache/IndexText.hs b/Data/TCache/IndexText.hs index 7c411ed..62473ab 100644 --- a/Data/TCache/IndexText.hs +++ b/Data/TCache/IndexText.hs @@ -169,7 +169,7 @@ indexText sel convert= do indexList :: (IResource a, Typeable a, Typeable b) => (a -> b) -- ^ field to index - -> (b -> [T.Text]) -- ^ method to convert a field element to Text (for example `pack . show` in case of elemets with Show instances) + -> (b -> [T.Text]) -- ^ method to convert a field element to Text (for example `pack . show` in case of elements with Show instances) -> IO () indexList sel convert= do addTrigger (indext sel convert) diff --git a/Data/TCache/Memoization.hs b/Data/TCache/Memoization.hs index 9930139..ed0d425 100644 --- a/Data/TCache/Memoization.hs +++ b/Data/TCache/Memoization.hs @@ -37,7 +37,7 @@ data Cached a b= forall m.Executable m => Cached a (a -> m b) b Integer deriving context = unsafePerformIO newContext -- | given a string, return a key that can be used in Indexable instances --- Of non persistent objects, such are cached objects (it changes fron execution to execution) +-- Of non persistent objects, such are cached objects (it changes from execution to execution) -- . It uses `addrHash` addrStr :: a -> String addrStr x= "addr" ++ show hash diff --git a/Data/TCache/Triggers.hs b/Data/TCache/Triggers.hs index 6953266..3bd56e4 100644 --- a/Data/TCache/Triggers.hs +++ b/Data/TCache/Triggers.hs @@ -26,9 +26,9 @@ cmtriggers = unsafePerformIO $ newIORef [] {- | Add an user defined trigger to the list of triggers -Trriggers are called just before an object of the given type is created, modified or deleted. +Triggers are called just before an object of the given type is created, modified or deleted. The DBRef to the object and the new value is passed to the trigger. -The called trigger function has two parameters: the DBRef being accesed +The called trigger function has two parameters: the DBRef being accessed (which still contains the old value), and the new value. If the DBRef is being deleted, the second parameter is 'Nothing'. if the DBRef contains Nothing, then the object is being created diff --git a/demos/DBRef.hs b/demos/DBRef.hs index b4f773b..ecc4b75 100644 --- a/demos/DBRef.hs +++ b/demos/DBRef.hs @@ -102,7 +102,7 @@ main = do let myCompanyRef2 = read $ show myCompanyRef :: DBRef Company putMsg "DBRefs are identified by the key of the referenced object" - putMsg "DBRef's are alse instances of read" + putMsg "DBRef's are also instances of read" print myCompanyRef2 putMsg "DBReference's with the same key point to the same data object" @@ -114,7 +114,7 @@ main = do putMsg "Before salary increase, the company personnel is accessed with the second reference" printSalaries myCompanyRef2 - putMsg "atomically increase the salaries of all the personel" + putMsg "atomically increase the salaries of all the personnel" atomically $ increaseSalaries 10 putMsg "after the increase" printSalaries myCompanyRef2 diff --git a/demos/caching.hs b/demos/caching.hs index e5efd80..3aea69d 100644 --- a/demos/caching.hs +++ b/demos/caching.hs @@ -40,9 +40,9 @@ main = do putStrLn "" putStrLn "This program tests the caching, cleaning, re-retrieval and updating of the cache." putStrLn "It uses the DefaultPersistence (disk) and defaultCheck (cleaning rules)." - putStrLn "It writes asyncronously every 10 seconds all changed elemements to disk." + putStrLn "It writes asynchronously every 10 seconds all changed elements to disk." putStrLn "When there is more than the allowed number of elements (100) in the cache it cleans them by the given rule." - putStrLn "With defaultCheck it drops elements which where not accesed since half the time between now and the last sync." + putStrLn "With defaultCheck it drops elements which where not accessed since half the time between now and the last sync." putStrLn "" putStrLn "Creating 200 resources with content: n 0" diff --git a/demos/triggerRelational.lhs b/demos/triggerRelational.lhs index b033124..22cd8e1 100644 --- a/demos/triggerRelational.lhs +++ b/demos/triggerRelational.lhs @@ -92,7 +92,7 @@ So a better version of addCar is: > Nothing -> return True > Just Car{owner= pother} -> > if pother== powner -> then return False -- is unchanged, not necesary to update +> then return False -- is unchanged, not necessary to update > else do > deleteOwner pother pcar > return True