Skip to content

Commit

Permalink
conversion from old markdown to new format
Browse files Browse the repository at this point in the history
  • Loading branch information
avsm committed Dec 22, 2013
1 parent d9adef3 commit 8974a70
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 48 deletions.
8 changes: 4 additions & 4 deletions tmpl/wiki/cow.md
Expand Up @@ -17,7 +17,7 @@ Most of the work is done at pre-processing time, so there is no runtime costs an

<img src="/graphics/cow-schema.png" alt="schema" width="50%"/>

!!!!Quotations and anti-quotations
####Quotations and anti-quotations

Camlp4 quotations are an easy way to manipulate the OCaml syntax tree and embed custom syntax.
Quotations are named, and are enclosed between `<:name< ... >>`.
Expand Down Expand Up @@ -104,7 +104,7 @@ let js2 : Javascript.t =

The `<:css< >>`, `<:xml< >>` and `<:html< >>` quotations are present in Mirage today, and the `<:js< >>` and `<:camlscript< >>` quotations will be integrated soon. `js` uses Jake Donham's [ocamljs](https://github.com/jaked/ocamljs) and an early prototype of `camlscript` is [available](https://github.com/samoht/camlscript) on Github.

!!!Type-driven Code Generation
###Type-driven Code Generation

In ML, we rely on the type-inferrer/checker as much as possible. Types are usually specified first, followed by the functions which manipulate values of those types.
The static typing in OCaml means that type information is discarded at run-time, making it cheap to encode as much of the problem in the types as possible.
Expand Down Expand Up @@ -190,7 +190,7 @@ auto-generating this. However, it may be possible to generate a CSS validator to
check that the CSS fragment generated for a type does not define classes which are not defined
in the type.

!!!!More code generation
####More code generation

The next step is to use the Twitter API to actually read tweets? The API uses JSON, and most of the
existing implementations use a JSON un-marshaler to association lists, and then build an ML object out of it
Expand Down Expand Up @@ -221,7 +221,7 @@ It is possible to combine multiple code generators by separating the annotations
`type t = [..] with html,json`. It is thus possible to use Cow with the [ORM](https://www.github.com/mirage/orm)
library to persist typed values with SQLite (this is not integrated into Mirage just yet, but will be soon).

!!!!Mixing generated and hand-written code
####Mixing generated and hand-written code

Manual and automatic code generation can also be easily mixed. The code which is auto-generated simply calls
into other functions with predictable names (e.g. `html_of_foo`). Since OCaml is lexically scoped, the user simply
Expand Down
10 changes: 5 additions & 5 deletions tmpl/wiki/delimcc-vs-lwt.md
Expand Up @@ -30,7 +30,7 @@ We can now use the `bind` function to do something after the sleep is complete:

`x` has the type `unit Lwt.t`, and the closure passed to `bind` will eventually be called with `unit` when the sleep finishes. Note that we also need a function to actually begin evaluating an Lwt thread, which is the `run` function.

!!Concerns
##Concerns

Mirage currently uses Lwt extensively, and we have been very happy with using it to build a network stack. However, I was surprised to hear a lot of debate at the [2011 OCaml Users Group](http://anil.recoil.org/2011/04/15/ocaml-users-group.html) meeting that Lwt is not to everyone's tastes. There are a few issues:

Expand All @@ -47,7 +47,7 @@ Lwt addresses the first problem via a comprehensive [syntax extension](http://oc

The `lwt` keyword indicates the result of the expression should be passed through `bind`, and this makes it possible to write code that looks more OCaml-like. There are also other keywords like `for_lwt` and `match_lwt` that similarly help with common control flow constructs.

!!Fibers
##Fibers

After the meeting, I did get thinking about using alternatives to Lwt in Mirage. One exciting option is the [delimcc](http://okmij.org/ftp/continuations/implementations.html) library which implements [delimited continuations](http://en.wikipedia.org/wiki/Delimited_continuation) for OCaml. These can be used to implement restartable exceptions: a program can raise an exception which can be invoked to resume the execution as if the exception had never happened.
Delimcc can be combined with Lwt very elegantly, and Jake Donham did just this with the [Lwt_fiber](http://ambassadortothecomputers.blogspot.com/2010/08/mixing-monadic-and-direct-style-code.html) library. His post also has a detailed explanation of how `delimcc` works.
Expand All @@ -61,7 +61,7 @@ The interface for fibers is also simple:

A fiber can be launched with `start`, and during its execution can block on another thread with `await`. When it does block, a restartable exception saves the program stack back until the point that `start` was called, and it will be resumed when the thread it blocked on completes.

!!Benchmarks
##Benchmarks

I put together a few microbenchmarks to try out the performance of Lwt threads versus fibers. The fiber test looks like this:

Expand Down Expand Up @@ -157,7 +157,7 @@ We then run the experiment using the slow `Lwt_unix.sleep 0.0` function, and get

The above graph shows the recursive Lwt_fiber getting slower as the recursion depth increases, with normal Lwt staying linear. The graph also overlays the non-recursing versions as a guideline (`*-basic-slow`).

!!Thoughts
##Thoughts

This first benchmark was a little surprising for me:

Expand All @@ -168,7 +168,7 @@ This first benchmark was a little surprising for me:

I need to stress that these benchmarks are very micro, and do not take into account other things like memory allocation. The standalone code for the tests is [online at Github](http://github.com/avsm/delimcc-vs-lwt), and I would be delighted to hear any feedback.

!!Retesting recursion [18th Jun 2011]
##Retesting recursion [18th Jun 2011]

Jake Donham comments:
> I speculated in my post that fibers might be faster if the copy/restore were amortized over a large stack. I wonder if you would repeat the experiment with versions where you call fn only in the base case of sum, instead of at every call. I think you're getting N^2 behavior here because you're copying and restoring the stack on each iteration.
Expand Down
6 changes: 3 additions & 3 deletions tmpl/wiki/dev-preview-checklist.md
@@ -1,6 +1,6 @@
!Developer Preview Checklist

!!Scenarios
##Scenarios

Three scenarios need to work:

Expand All @@ -10,7 +10,7 @@ Three scenarios need to work:

* Proof concept of distributed system (ideally can be demo'd for OSCON). Current thinking is something like OCamlot or Signpost. This would be a nice "Hello world!" demo as it requires actors and a persistent job queue. For example, i.e spawning new VMs in response to load, as evidenced by self-scaling web-server.

!!Repositories
##Repositories

All of these repositories need to be code-reviewed and run over with ocamldoc. Purge the TODO hacks when you go over them, or explicitly pull them out into a top-level TODO file.
We need to close out this thread on a standard [repository format](https://lists.cam.ac.uk/pipermail/cl-mirage/2013-March/msg00099.html) for all these things.
Expand Down Expand Up @@ -88,7 +88,7 @@ Tutorials and examples:
* *mirage-tutorial*: out-of-date
* *mirage-www*: extract wiki/blog into library, make it not suck

!!Misc
##Misc

* Integrate `ocaml-tuntap` into `mirage-platform` to remove tun hacks [vincent]
* `mirari run` as a stateful process working with libvirt and EC2.
Expand Down
4 changes: 2 additions & 2 deletions tmpl/wiki/htcaml.md
Expand Up @@ -4,7 +4,7 @@ and explain how to use it to generate static HTML from within OCaml applications
* a quotation mechanism to embed XML into an OCaml program.
* a syntax extension to auto-generate boilerplate HTML definitions from OCaml type definitions.

!!HTML quotations
##HTML quotations

Let us first focus on the quotation mechanism. This part is quite
similar to the syntax extension provided by
Expand Down Expand Up @@ -118,7 +118,7 @@ let () =
close_out chan
```

!!HTML Generator
##HTML Generator

Some of the OCaml code we wrote in the last section is quite tedious
to write. Let us consider `html_of_tweet` again:
Expand Down
2 changes: 1 addition & 1 deletion tmpl/wiki/install.md
@@ -1,6 +1,6 @@
Mirage consists of a set of OCaml libraries that link with a runtime to form either a standalone Xen operating system or a normal UNIX binary. These libraries are managed via the [OPAM](http://opam.ocaml.org) tool. After describing Mirage's system requirements, we will introduce the basics of OPAM and setting up for Mirage.

!!Requirements
##Requirements

Mirage has been tested on ArchLinux, Debian Wheezy, Ubuntu Precise/Lucid/Raring/Saucy, CentOS 6.4 and MacOS X 10.8 and 10.9. To compile the Xen backend, you *must* have a 64-bit Linux host. 32-bit is not supported at this time.

Expand Down
8 changes: 4 additions & 4 deletions tmpl/wiki/ocaml-regexp.md
Expand Up @@ -5,7 +5,7 @@ closer to the application level, it is necessary to either reimplement the C
bindings in Javascript or OCaml, or remove them completely. This is particularly
important for the standard library.

!!The `Str` module has to go!
##The `Str` module has to go!

`Str` provides regular expressions in a non-reentrant, non-functional fashion.
While the OCaml distribution provides it in `otherlibs`, it is installed by
Expand All @@ -30,7 +30,7 @@ set of perks and drawbacks:
be slower than `Str` and needed an estimation of performance cost in order to
assess the practicality of the solution.

!!Benchmarking `Str`
##Benchmarking `Str`

There is a purely OCaml regexp library readily available, called `Regexp` and
developed by Claude Marché from the LRI laboratory. You can find the
Expand Down Expand Up @@ -62,7 +62,7 @@ Quite surprisingly for the string matching operation, the C based `Str` module
is less efficient than the pure OCaml `Regexp`. The `Pcre` results were even worse
than `Str`. Why?

!!!A simple library for a simple task
###A simple library for a simple task

The `Regexp` library is lightweight, and so far faster than its C based
counterparts. One of the features `Regexp` lacks is "group capture": the ability
Expand All @@ -72,7 +72,7 @@ instead of the regular parentheses. `Str` does not offer this, and thus
imposes the runtime cost of capture even when not necessary. In other words, the
slowdown/group capturing "is not a feature, it's a bug!"

!!!The Mirage Regexp library
###The Mirage Regexp library

With the introduction of `Regexp` into the tree, the libraries available to Mirage
applications are now `Str`-free and safer to use across multiple backends. The main
Expand Down

0 comments on commit 8974a70

Please sign in to comment.