• Stars
    star
    126
  • Rank 284,543 (Top 6 %)
  • Language
    Haskell
  • License
    MIT License
  • Created almost 15 years ago
  • Updated about 14 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

REST'ful web framework in Agda

Lemmachine

Status

A proof of concept of compositonal web app testing (described below) can be shown satisfactorily using this branch. Current work is towards a complete static validator for HTTP 0.9 + 1.0 (a requirement of HTTP 1.1, which will be the subsequent work effort).

Description

Lemmachine is a REST'ful web framework that makes it easy to get HTTP right by exposing users to overridable hooks with sane defaults. The main architecture is a copy of Erlang-based Webmachine, which is currently the best documentation reference (for hooks & general design).

Lemmachine stands out from the dynamically typed Webmachine by being written in dependently typed Agda. The goal of the project is to show the advantages gained from compositional testing by taking advantage of proofs being inherently compositional. See proofs for examples of universally quantified proofs (tests over all possible input values) written against the default resource, which does not override any hooks.

When a user implements their own resource, they can write simple lemmas ("unit tests") against the resource's hooks, but then literally reuse those lemmas to write more complex proofs ("integration tests"). For examples see some reuse of lemmas in proofs.

The big goal is to show that in service oriented architectures, proofs of individual middlewares can themselves be reused to write cross-service proofs (even higher level "integration tests") for a consumer application that mounts those middlewares. See this post for what is meant by middleware.

Another goal is for Lemmachine to come with proofs against the default resource (as it already does). Any hooks the user does not override can be given to the user for free by the framework! Anything that is overridden can generate proofs parameterized only by the extra information the user would need to provide. This would be a major boost in productivity compared to traditional languages whose libraries cannot come with tests for the user that have language-level semantics for real proposition reuse!

Lemmachine currently uses the Haskell Hack abstraction so it can run on several Haskell webservers. Because Agda compiles to Haskell and has an FFI, existing Haskell code can be integrated quite easily.

Setup

Grab Haskell if you don't already have it installed.

cabal update
cabal install hack hack-handler-happstack Agda-executable

Add Cabal binaries to your PATH in ~/.profile: export PATH=~/.cabal/bin:$PATH

Make sure you have Agda version 2.2.6: agda --version

Development

Get Emacs to work with Agda.

Examples of how to use agda-mode.

We use a vendored modified Agda stdlib, so in Emacs: M-x customize-group agda2

Then add this to Agda2 Include Dirs: ./vendor/stdlib/src

Running

Run the following to see this in action for Lemmachine.Default: agda -c --compile-dir=. --ghc-flag=-isrc -i src -i vendor/stdlib/src src/Lemmachine/Default.agda ./Default

In a separate terminal, see a 200 response: curl -X GET -H "Accept: text/html" -i http://localhost:3000 && echo

... compared to a 406 due to requesting an unsupported text/xml media type: curl -X GET -H "Accept: text/xml" -i http://localhost:3000 && echo

... compared to a 405 due to requesting an unsupported POST method: curl -X POST -H "Accept: text/html" -i http://localhost:3000 && echo

All of this is just default behavior and can be overridden by defining appropriate hook methods.

Even though we are working in a language with a lot of verification power, the amount of code required for a complete runnable application remains competitive with more mainstream languages: module ItsSoEasy where open import Lemmachine main = runResolve (toApp [])

More Repositories

1

dataflow

Dataflow concurrency for Ruby (inspired by the Oz language)
Ruby
124
star
2

dtgp

Dependently Typed Genetic Programming
22
star
3

cry

A CommonLisp CLOS-like parse tree library for Ruby... read (and write) it and weep.
Ruby
22
star
4

revolve

Flexible Ruby stack-based Genetic Programming
Ruby
19
star
5

leveling-up

Source code accompanying the paper "Leveling Up Dependent Types"
18
star
6

buzzer

Creating a buzzword detector: A Git-powered Clojure tutorial (Gitorial)
Clojure
17
star
7

specjure

Behaviour Driven Development framework for Clojure
Clojure
15
star
8

neurosis

Ruby Sinatra REST frontent to simple Haskell MLP Neural Network (AKA Hubris Haskell->Ruby bridge demo)
Haskell
14
star
9

generic-elim

Source code accompanying the paper "Generic Constructors and Eliminators from Descriptions"
TeX
11
star
10

linear-temporal-logic

sandbox for playing with linear temporal logic
Agda
8
star
11

spire

The Spire Programming Language
Haskell
7
star
12

generic-reuse

Source code accompanying the draft paper "Generic Zero-Cost Reuse for Dependent Types"
TeX
6
star
13

uAgda

[UNOFFICIAL FORK] Making uAgda work with ghc 7.4.1
Haskell
5
star
14

pigit

seeing what Epigram looks like after a darcs-fastconvert (NOT AN OFFICIAL MIRROR)
Haskell
4
star
15

zero-cost-coercions

Source code accompanying the draft paper "Zero-Cost Coercions for Program and Proof Reuse"
TeX
4
star
16

mltt-lecture

TeX
3
star
17

plclub-expless

PL Club talk on Expressionless Weak-Head Normal Forms
Agda
3
star
18

idbein-ruby

JavaScript
3
star
19

pigeons-blood

Ruby methods that can be used in place of language keywords.
Ruby
3
star
20

paralyze

Various way to run RSpec in parallel and Paralyze computers running it.
Ruby
3
star
21

agda-rb

Haskell
3
star
22

scotrubyconf

[presentation] Dependent Types: A Look At The Other Side
Ruby
2
star
23

thesis

Agda
2
star
24

gp

Genetic Programming in Clojure
Clojure
2
star
25

clspec

Behaviour Driven Development framework for Common Lisp
Common Lisp
2
star
26

sbe

Accompanying source code for technical report "Hereditary Substitution by Canonical Evaluation (SbE)".
TeX
2
star
27

carroll

Toy implementation of the declarative Oz kernel language
Ruby
1
star
28

expless

Adaptation of Ch. 4 of James Chapman's thesis to Values and Hereditary Substitution (note to self: currently missing some theorems still on laptop)
TeX
1
star
29

buffer-overflows

JavaScript
1
star
30

plclub-oct-2012

Code for a PL Club I gave at PSU on October 26, 2012
1
star
31

plclub-apr-2013

Code for a PL Club I gave at PSU on April 19, 2013.
1
star
32

dtp10

presentation i gave at a dependent types workshop when i was more naive than now
Ruby
1
star
33

methodical

"Think before you call methods"
Ruby
1
star
34

random-bug-walk

Random Bug Walk assignment for UCF - CET 4523 - Applied System Analysis II
Ruby
1
star
35

abstract-theory

I think this was code i played with while preparing for the galois tech talk i gave
1
star