The crjdt-haskell package

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain]

A Conflict-Free Replicated JSON Datatype for Haskell


[Skip to ReadMe]

Properties

Versions0.1.0.0, 0.2.0.0, 0.2.1, 0.2.1, 0.3.0
Change logCHANGELOG.md
Dependenciesbase (>=4.7 && <5), containers (>=0.5.0.0 && <0.6), crjdt-haskell, free (>=4.6.1 && <5), mtl (>=2.2.1 && <2.3), text (>=0.11.1.0 && <1.3) [details]
LicenseBSD3
Copyright2017 Amar Potghan
AuthorAmar Potghan
Maintaineramarpotghan@gmail.com
CategoryData
Home pagehttps://github.com/amarpotghan/crjdt-haskell#readme
Source repositoryhead: git clone https://github.com/amarpotghan/crjdt-haskell
Executablesexamples
UploadedMon May 8 13:58:00 UTC 2017 by amarpotghan

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for crjdt-haskell-0.2.1

Build Status

A Conflict-Free Replicated JSON Datatype for Haskell

crjdt-haskell provides high level interface to CRDT which is formalised in the paper by Martin Kleppmann and Alastair R. Beresford.

Documentation

See haddocks.

Example


{-# LANGUAGE OverloadedStrings #-}
module Main where

import Data.Crjdt as C

-- Original state
original :: Command ()
original = (doc .> key "key") =: "A"

-- First replica updates doc["key"] to "B"
replica1 :: Command ()
replica1 = do
  original
  (doc .> key "key") =: "B"

-- Second replica updates doc["key"] to "C"
replica2 :: Command ()
replica2 = do
  original
  (doc .> key "key") =: "C"

main :: IO ()
main = do
  -- Sync first and second replica
  let Right (r1, r2) = sync (1, replica1) (2, replica2)

  let replica1' = execEval 1 r1
      replica2' = execEval 2 r2

  -- Both replicas converge to: {"key": {"B", "C"}}
  print (document replica1' == document replica2') -- True

Future work

LICENSE

Copyright © 2017 Amar Potghan

Distributed under BSD License.