DPella
The course uses a programming framework called DPella, which stands for Differential Privacy in Haskell with Accuracy. To use DPella, you need to download and install a Docker image.
Downloading
We have prepared a Docker image which consists on the Haskell Interpreter and Compiler 8.2.2 together with DPella. So far, we have only an image for those using Linux.
- Linux users: dpella.tar.gz
Installing
To install the downloaded image in your machine, you should run the following command:
docker import --change "ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/cabal/2.2/bin:/opt/ghc/8.2.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" --change "ENV LANG C.UTF-8" --change "CMD [\"ghci\"]" - dpella:install < dpella.tar.gz
Launching DPella
Linux users: Before we start, you need to understand a little bit of the docker setup. You should choose a directory in your machine where you will place your DPella programs. I am going to assume that such directory is the folder
rio2020local
in your home directory.We are going to mount that directory when launching the docker image:
docker run -it --mount type=bind,source="$(pwd)"/rio2020local,target=/rio2020 dpella:install
and you should get the Haskell prompt.
GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help Prelude>
To load DPella using the Laplace Mechanism, you should run the following command:
Prelude> module DPella Prelude DPella>
Now, you should have the API to start programming your deferentially private queries!
Prelude> :t budget Prelude> :t accuracy
Programming
You can use your favorite editor to create your DPella programs in the
directory rio2020local
(recall the previous point). Once you finish editing
your files, you can try them by accessing the rio2020
directory in the
docker image---which points to your rio2020local
directory---and load them!
Prelude>:cd rio2020
Prelude>:l <YourDPellaCode.hs>
There are a couple of Haskell's interpreter commands very useful to learn, e.g., how to list all the files in a directory.
Prelude>:!ls
Haskell Documentation
If you want to explore the Haskell programming language, we have provided some useful links below.
- GHC is well documented.
- To start being familiar with the interpreter, you can take a look to Chapter 4 of the the user's guide.
- If you are new to Haskell, forget some functions names and their types, then Hoogle is an excellent tool for you! Hoogle is like a Google search for the Haskell language. You can indicate the name or type of the function that you want to know something about it, and Hoogle will do the rest.
- If you want to know more about functional programming and Haskell, you can read online the book Real World Haskell (Chapter 1 to 13) by B. O'Sullivan, D. Stewart, and J. Goerzen.