Giter Site home page Giter Site logo

social-example's Introduction

This project accompanies my master's thesis and contains the full source code of the example application built in chapter 4. It is intended as a demonstration of STM finalizers and transactional tries.

A finalizer is an arbitrary I/O action that can be attached to an STM transaction using the function

atomicallyWithIO :: STM a -> (a -> IO b) -> IO b

A full specification of STM finalizers, including an operational semantics and a discussion of their implementation in GHC, as well as plenty of other examples of their use, can be found in my thesis.

Example: A simple social network

The folders social0, social1and social2 contain a modest social networking application, in various stages of completion. They all contain a Haskell web server exposing a RESTful API (Server.hs) and a JavaScript client (client.html), but the interesting stuff happens in the site's back-end (SocialDB.hs). There, the network's data is managed using STM.

  • The social0 version uses just STM, meaning the whole database stays purely in-memory.

  • In social1, we use a lightweight reusable database framework built on top of STM with finalizers. The framework itself can be found in the tx folder.

  • The social2 version demonstrates schema migration: it has some additional features, so its data types differ from the previous version; but thanks to SafeCopy, we can still open the old database file and continue seamlessly.

All versions make use of transactional tries.

Simulating finalizers

In order for the examples to work, you either need a patched version of GHC that supports STM finalizers or you can just compile with the -DSIMULATE_FINALIZERS flag, e.g.

cabal repl social1 --ghc-options="-DSIMULATE_FINALIZERS"

social-example's People

Contributors

mcschroeder avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.