Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
example package for class at BayHac 2014 on development with the Haste compiler
branch: master
Failed to load latest commit information.
contrib Fix broken merge
lib remove unused code
slides add revealjs sources
src fix native build
test init
.gitignore add revealjs sources
.hgignore init
LICENSE init
Main.html move forms in Main.html to the center of the screen
README.md
bayhac2014-cryptmail.cabal bump version

README.md

This package contains code for an example Web application for a class at BayHac2014. The application allows to create encrypted emails from within a browser.

This is not production level code.

The purpose of this package to demonstrate techniques for development of portable Haskell libraries that can be used with native compilations as well as cross-compilations to client-side javascript via the Haste compiler.

Slides

http://alephcloud.github.io/bayhac2014/slides/index.html

Overview

The package includes a library component that can be compiled with native GHC as well as with the Haste compiler. The library exposes two interfaces:

  1. a Haskell API for encryption and decryption with a password and
  2. a JSON service API that wraps the Haskell API in JSON data types.

The package further contains an application that serves the JSON API over HTTP using scotty.

The package also contains an application that exports the JSON API as client side javascript module.

Finally, there is a cabal test suite for unit testing the library with a native compilation.

Setup of Haste with a Sandbox

The following instructions installs the haste-compiler in a cabal sandbox. Note, however, that the resulting haste-compiler itself is not using a sandbox for compilations.

Build Haste:

cabal sandbox init
echo 'constraints: scientific<0.3' >> cabal.config
cabal install haste-compiler -j
export PATH=./.cabal-sandbox/bin:$PATH

Setup Haste:

echo 'solver: topdown' >> ~/.cabal/config
haste-boot
sed -i '/solver: topdown/d' ~/.cabal/config

If haste-boot failes with an error message that inlcude the text only already installed instances can be used you may try to temporarily add the following to your ~/.cabal/config while running haste-boot.

Installation

The native version of the library and the server application can be installed via

cabal install

The test suite can be run via

cabal configure --enable-tests
cabal build
cabal test

The javascript module is build via

mv cabal.sandbox.config cabal.sandbox.config.disabled
haste-inst install -fhaste
haste-inst configure -fhaste
haste-inst build

The resulting javascript code is in the file src/Client.js. It can be tested by opening the file Main.html in a browser from the root directory of the package.

Legal Notes

This package includes a copy of a version of SJCL in the file ./lib/sjcl.js. SJCL is hosted at https://github.com/bitwiseshiftleft/sjcl and distributed under a BSD license as described at http://bitwiseshiftleft.github.io/sjcl.

The file ./src/BayHac2014/Cryptmail/Json.hs and the files in the directory ./src/BayHac2014/Cryptmail/Json of this package in part contain code that was copied, derived, or inspired by the Aeson package. The Aeson package is distributed under a BSD3 License and copyright of (c) 2011-2014 Bryan O'Sullivan (c) 2011 MailRank, Inc.. A copy of the LICENSE of the Aeson package can be found here.

Something went wrong with that request. Please try again.