A library implementing the Carol programming language, providing an eDSL for writing operations and a replica system that runs them.
First, get the project.
$ git clone https://github.com/cuplv/card-systems
$ cd card-systems
Next, build the project. If you have the nix
package manager, the process is simple:
$ nix-env -i cabal2nix cabal-install
$ cabal2nix --shell . > shell.nix
$ nix-shell --command "cabal configure"
$ cabal build
The current demo executable is a simple conflict-aware bank account,
in which replicas announce updates via http and store their history in
IPFS. To try it, first make sure there is an IPFS daemon running
with it's API on port 5001
(the default).
$ nix run nixpkgs.ipfs -c ipfs daemon --init
Then, open two terminals, and run the following:
(term 1)$ cabal run discard-demo -- -c 2local.yaml -i alpha
(term 2)$ cabal run discard-demo -- -c 2local.yaml -i beta
Now a node is running in each terminal. Choose one and type dp INT
to add money to the account, or withdraw with wd INT
. You should
see the balance changes reflected in the other node's interface.
Try testing the safety of the system by running wd INT
with enough
value to empty the account simultaneously on two nodes.
You can edit Main.hs
to see how the library is used and make a
more interesting example. The bank operations, written in the Carol
language, are defined in Bank.hs
.
Library documentation, which is still minimal and disorganized, can be
compiled with cabal haddock
.
If you don't have Nix, here's another way to set up the system (that hasn't been tested in a while...)
- Install ipfs
- Install stack
- Execute the following command within the repo:
$ stack setup
- To build and run the code, use the commands,
$ stack build $ stack exec cardr