Friday, October 31, 2014

Irmin Irmin on the wall, who is the pretiest of them all - Moana

I am currently working on MoanaML.

My recent challenge was to code a backend based on Mirage/Irmin.

Ok, first thing first, what is Moana:

Moana, an information-centric middleware for distributed services and applications. Moana offers a shared graph-based storage abstraction through which applications communicate with each other by appending and observing the shared graph.
Moana supports two basic operations of ADD and MAP; add allows an application to persistently extend the global graph, and map provides a dynamically maintained mapping of the global graph to an application specific, internal sub-graph.
MoanaML is an implementation of the Moana primitives in OCaml.

Now, what is Irmin:

Irmin is a distributed database with built-in snapshot, branch and revert mechanisms. It is designed to use a large variety of backends, although it is optimized for append-only store.
 
Just  to recap, at the moment, MoanaML contains:

Here I wanted to summaries some of my initial progress on developing the Irmin backend for Moana.

To code Irmin-based backed we need to implement two Moana signatures, namely STORE and GRAPH

I am a noobie when it comes to Irmin, I am still trying to figure out all of its functionalities so proceed with caution :)

I recommend reading this blog post to get a better understanding on Irmin, also I found this short paper very insightful. For better code understanding, make sure you familiarise yourself with the lwt library.

So to use Irmin, I chose to use blocks of type String, just because it is provided; to have different types of values you need to implement your own IrminContents signature. This, from my understanding, involves letting Irmin know how to merge your values.

Ultimately, I want to use Irmin to store Moana tuples, not strings, so I will have to implement the Contents signature. For now, I convert Moana tuples into JSON string and store them in Irmin.

Now to the code...


Following Irmin examples, I first implemented t_of_view  and view_to_t functions to convert list of tuples to view and take list of tuples from the view, respectively. I later use these functions to store the views inside Irmin.

The cool thing about Irmin that all  my data is stored in git.

Thanks to this:

module Git =
  IrminGit.FS(struct let root = Some "/tmp/irmin/moana"
                        let bare = true
                           end)
 
(* Values are Strings * *)
module Store = Git.Make(IrminKey.SHA1)(IrminContents.String)(IrminTag.String)

You can also visualise it!




Thursday, October 23, 2014

MoanaML - status report

I have started to work on implementing Moana key functional primitives in OCaml.

The code is available on github here.


My last commit included implementation of the join AM BM  function which binds the tuples available in AM with the intermediate "solution" tuples in the BM. The concepts are taken from the RETE  algorithm. However, unlike RETE this  is still a "static system". By that I mean that join operations are performed on pre-populated AMs.

RETE's left/right activations allow for a more dynamic system. The idea is that each time a new tuple is added to an AM right activation is performed which triggers left activation from the BM, a sequence of these activation will lead to a new result in the newly created final BM.

This is my next step...along with writing more unit tests and fixing existing bugs. If you have any cool ideas on how to take MoanaML further feel free to contribute and Pull Request.
 


Monday, October 6, 2014

Ocaml teaching resources

[Update: The Ocaml teaching resource page is now live]

I am helping the folks behind OCaml.org with setting up a page that will useful resources for educators that want to teach OCaml to masses.

We are looking to include helpful guides on how to setup a development environment, provide links to useful VMs as well as list some tips for complete beginners. There is a lot of material on the web, however it is scattered all over the places and sometimes hard to find. We will try to find the best of the lot and have them referenced in one place.

Watch this space...I really meant this space.

We are also listing all the universities where OCaml is being taught.

Let us know if we missed any.

It is great to see them on the Google maps as well :)