https://github.com/amarpotghan/crjdt-haskell
A Conflict-Free Replicated JSON Datatype for Haskell
https://github.com/amarpotghan/crjdt-haskell
crdt haskell json
Last synced: 4 months ago
JSON representation
A Conflict-Free Replicated JSON Datatype for Haskell
- Host: GitHub
- URL: https://github.com/amarpotghan/crjdt-haskell
- Owner: amarpotghan
- License: bsd-3-clause
- Created: 2017-03-29T19:06:35.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-07-14T21:04:50.000Z (almost 8 years ago)
- Last Synced: 2026-01-08T10:19:08.756Z (6 months ago)
- Topics: crdt, haskell, json
- Language: Haskell
- Homepage: http://hackage.haskell.org/package/crjdt-haskell
- Size: 94.7 KB
- Stars: 34
- Watchers: 6
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/amarpotghan/haskell-crjdt)
# A Conflict-Free Replicated JSON Datatype for Haskell
*crjdt-haskell* provides high level interface to CRDT which is formalised in the [paper](https://arxiv.org/pdf/1608.03960v1.pdf) by Martin Kleppmann and Alastair R. Beresford.
## Documentation
See [haddocks](https://hackage.haskell.org/package/crjdt-haskell).
## Example
```haskell
{-# 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 = original *> doc .> key "key" =: "B"
-- Second replica updates doc["key"] to "C"
replica2 :: Command ()
replica2 = 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
* Improve documentation
* Aeson support
* Simplify API as described in [second version](https://arxiv.org/abs/1608.03960) of the paper
## Other implementations
* [Scala CRJDT](https://github.com/fthomas/crjdt)
## LICENSE
Copyright © 2017-2018 Amar Potghan
Distributed under BSD License.