indexation 0.4.2 → 0.4.2.1
raw patch · 4 files changed
+22/−5 lines, 4 filesdep +list-tdep +mmorphdep ~stm-containers
Dependencies added: list-t, mmorph
Dependency ranges changed: stm-containers
Files
- indexation.cabal +4/−2
- library/Indexation/IO.hs +3/−3
- library/Indexation/Prelude.hs +8/−0
- library/Indexation/Vector.hs +7/−0
indexation.cabal view
@@ -1,5 +1,5 @@ name: indexation-version: 0.4.2+version: 0.4.2.1 category: Data synopsis: Tools for entity indexation description: A set of tools for indexing entities@@ -37,10 +37,12 @@ deferred-folds >=0.6 && <0.7, focus >=1.0.1 && <1.1, hashable >=1 && <2,+ list-t >=1 && <1.1,+ mmorph >=1 && <2, potoki >=2 && <2.1, potoki-cereal >=0.3 && <0.4, profunctors >=5.2 && <6,- stm-containers >=1 && <1.1,+ stm-containers >=1.0.1 && <1.1, text >=1 && <2, transformers >=0.5 && <0.6, unordered-containers >=0.2.9 && <0.3,
library/Indexation/IO.hs view
@@ -39,9 +39,9 @@ freezeIndexerAsVector :: Indexer entity -> IO (Vector entity) freezeIndexerAsVector (Indexer sizeVar map) =- atomically $ do- size <- readTVar sizeVar- Vector.unfoldM size (fmap swap (StmMap.unfoldM map))+ do+ size <- atomically (readTVar sizeVar)+ Vector.listTInIO size (hoist atomically (fmap swap (StmMap.listT map))) freezeIndexerAsEntityTable :: Indexer entity -> IO (EntityTable entity) freezeIndexerAsEntityTable = fmap EntityTable . freezeIndexerAsVector
library/Indexation/Prelude.hs view
@@ -118,3 +118,11 @@ import Potoki.Produce as Exports (Produce) import Potoki.Consume as Exports (Consume) import Potoki.Transform as Exports (Transform)++-- mmorph+-------------------------+import Control.Monad.Morph as Exports hiding (MonadTrans(..))++-- list-t+-------------------------+import ListT as Exports (ListT(..))
library/Indexation/Vector.hs view
@@ -6,6 +6,7 @@ import qualified Data.Vector.Mutable as A import qualified Data.HashMap.Strict as B import qualified DeferredFolds.UnfoldM as UnfoldM+import qualified ListT {-|@@ -51,3 +52,9 @@ UnfoldM.foldlM' step mv unfoldM !iv <- return (unsafeDupablePerformIO (unsafeFreeze mv)) return iv++listTInIO :: Int -> ListT IO (Int, element) -> IO (Vector element)+listTInIO size listT = do+ mv <- A.unsafeNew size+ flip ListT.traverse_ listT $ \ (index, element) -> A.write mv index element+ unsafeFreeze mv