View on GitHub

mdr-haskell

mdr, the markdown runner.

MDR, a markdown runner

Build Status

mdr is a small (less than 500 Haskell SLOC :champagne:) program and markup designed to facilitate documentation and testing.

logo

I started it to ease Gwion’s devellopment, but it is not tied in any way to this project.

Let’ walktrough… :smile:

Hello World

let’s write our first litterate progam.

Define program structure

@[[Includes]]

int main(int argc, char** argv) {
  @[[Print]]
}

Add Headers

As we need the puts function, we need stdio headers.

#include <stdio.h>
puts("Hello, World!");

Compile

with this line

@exec cc hello_world.c -o hello_world

we compile hello_world.c.

Yes, there should be no output, and that good news.

Check

Let’s look at hello_world.c

@exec cat hello_world.c
#include <stdio.h>

int main(int argc, char** argv) {
  puts("Hello, World!");
}

That’s the content of the source file we generated (and compiled).

Test

Then we run it

./hello_world
Hello, World!

Do we read Hello World! ? Assuming yes, let’s continue.

More test

Let’s try it

[ "$(./hello_world)" = "Hello, World!" ] && echo "OK" || echo "NOT_OK"

and the result is

OK

Building

As a haskell programm, it seemed natural to use cabal as a build system.

cabal build

Installing

As easy as before, just type.

cabal install

generated from this file