packages feed

dvv 0.1.1.0 → 0.1.2.0

raw patch · 5 files changed

+20/−11 lines, 5 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Data.DVV: VersionVector :: HashMap actorID Count -> [(Count, actorID)] -> VersionVector actorID
- Data.DVV: [vvDesc] :: VersionVector actorID -> [(Count, actorID)]
- Data.DVV: [vvMap] :: VersionVector actorID -> HashMap actorID Count
+ Data.DVV: extractComponents :: Hashable actorID => DVV actorID value -> (VersionVector actorID, HashMap (Dot actorID) value)
+ Data.DVV: getVersionVectorCounts :: VersionVector actorID -> HashMap actorID Count

Files

README.md view
@@ -2,7 +2,7 @@  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -A GHC-Haskell implementation of [**Dotted Version Vectors (DVV)**](https://gsd.di.uminho.pt/members/vff/dotted-version-vectors-2012.pdf), a data structure for tracking causality and resolving conflicts in distributed systems. This library is inspired by the canonical Erlang example implementation and leverages GHC to provide a safe and expressive API.+A GHC-Haskell implementation of [**Dotted Version Vectors (DVV)**](https://gsd.di.uminho.pt/members/vff/dotted-version-vectors-2012.pdf), a data structure for tracking causality and resolving conflicts in distributed systems. This library is inspired by the canonical [Erlang example implementation](https://github.com/ricardobcl/Dotted-Version-Vectors).  ## Table of Contents 
changelog.md view
@@ -1,3 +1,6 @@+# 0.1.2.0 [James R. Thompson](mailto:jamesthompsonoxford@gmail.com) February 2026+Hide VersionVector field accessors to force smart constructor usage+ # 0.1.1.0 [James R. Thompson](mailto:jamesthompsonoxford@gmail.com) January 2026 Fix broken ordering instances 
dvv.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               dvv-version:            0.1.1.0+version:            0.1.2.0 license:            MIT license-file:       LICENSE copyright:          2026-Present, James R. Thompson
src/Data/DVV.hs view
@@ -18,7 +18,9 @@   -- * Core Types   Count,   Dot (..),-  VersionVector (..),+  VersionVector,+  mkVersionVector,+  getVersionVectorCounts,   DVV (..),    -- * Operations@@ -31,15 +33,15 @@   lww,    -- * Analysis-  mkVersionVector,   size,+  extractComponents, ) where  import Algebra.PartialOrd (PartialOrd (..)) import Data.HashMap.Strict (HashMap) import qualified Data.HashMap.Strict as Map-import Data.Hashable (Hashable (hashWithSalt))+import Data.Hashable (Hashable (..)) import Data.List (foldl', foldl1', sortBy) import Data.Maybe (fromMaybe) import Data.Word (Word64)@@ -92,6 +94,10 @@     )  where   sortDesc keyFn = sortBy (\x y -> compare (keyFn y) (keyFn x))++-- | Helper to extract the map of counts from a VersionVector, we hide the other field accessors+getVersionVectorCounts :: VersionVector actorID -> HashMap actorID Count+getVersionVectorCounts (VersionVector m _) = m  {- | A Dotted Version Vector (DVV) consisting of a Causal History (Version Vector) and a set of concurrent values associated with Dots.
test/Spec.hs view
@@ -194,16 +194,16 @@         let ctx1 = context d1             ctxSync = context (sync d1 d2)          in all-              (\(k, v) -> Map.lookup k (vvMap ctxSync) >= Just v)-              (Map.toList (vvMap ctx1))+              (\(k, v) -> Map.lookup k (getVersionVectorCounts ctxSync) >= Just v)+              (Map.toList (getVersionVectorCounts ctx1))      it "event increases context counter for the actor" $       property $ \(d :: DVV ID Value) (actor :: ID) (val :: Value) ->         let ctx = context d             d' = event d (Just ctx) actor val             ctx' = context d'-            oldCount = Map.findWithDefault 0 actor (vvMap ctx)-            newCount = Map.findWithDefault 0 actor (vvMap ctx')+            oldCount = Map.findWithDefault 0 actor (getVersionVectorCounts ctx)+            newCount = Map.findWithDefault 0 actor (getVersionVectorCounts ctx')          in newCount `shouldBe` (oldCount + 1)      it "event with full context produces exactly one value" $@@ -236,9 +236,9 @@       property $ \(d :: DVV ID Value) ->         case d of           EmptyDVV -> True-          SingletonDVV actor _ -> Map.member actor (vvMap (context d))+          SingletonDVV actor _ -> Map.member actor (getVersionVectorCounts (context d))           DVV _ vals ->-            let ctx = vvMap (context d)+            let ctx = getVersionVectorCounts (context d)                 actors = [actor | Dot actor _ <- Map.keys vals]              in all (`Map.member` ctx) actors