Seb's Blog: RSS feed for tag: ocamlhttp://seb.mondet.org/blog/
Sat, 10 Dec 2011 12:46:34 -0500Sat, 10 Dec 2011 12:46:34 -0500Anyweb, Document Source Code The Way You Like<div class="p"> I was playing with Adam Chlipala's &ldquo;<a href="http://adam.chlipala.net/cpdt/">CPDT</a>&rdquo; book and I wanted to take notes on some notations. I also wanted to do it in a <a href="http://en.wikipedia.org/wiki/Literate_programming"><i>Literate Programming</i></a> way: in a <tt>.v</tt> Coq file with <a href="http://seb.mondet.org/bracetax/">a familiar and practical syntax</a>&nbsp;&hellip; </div>
<div class="p"> That's where <a href="http://seb.mondet.org/anyweb/">Anyweb</a> comes into play. </div>
<div class="p"> This one-day hack is a simple parser and printer which looks for special string-markers (like <tt>(*B</tt> and <tt>B*)</tt> in Coq or OCaml sources) and does <i>stuff</i> (like calling <tt>coqdoc</tt> or <tt>source-highlight</tt>) depending on where it is in the source. The transformer uses an automaton and a stack, so any kind of <i>recursive</i> embedding seems possible. </div>
<div class="p"> The <a href="https://github.com/smondet/anyweb/blob/master/anyweb.ml">code</a> is <i>of course</i> self-documenting (<a href="http://seb.mondet.org/anyweb/">HTML</a>, or <a href="http://seb.mondet.org/anyweb/anyweb.pdf">PDF</a>). The bunch of notes on CPDT which motivated the hack is also <a href="https://github.com/smondet/anyweb/blob/master/subset_notes.v">available</a> (<a href="http://seb.mondet.org/anyweb/coq_example.html">HTML</a>, and <a href="http://seb.mondet.org/anyweb/coq_example.pdf">PDF</a>). </div>
http://seb.mondet.org/blog/post/anyweb-document-source-code-the-way-you-like.html
http://seb.mondet.org/blog/post/anyweb-document-source-code-the-way-you-like.htmlTue, 19 Apr 2011 21:26:42 +0200Third Post; New Blog Engine<div class="p"> I got quickly annoyed by Wordpress' interface, and by the engine itself, and by those ugly themes, and&nbsp;&hellip; OK, let's stop bad-mouthing other people&nbsp;&hellip; </div>
<div class="p"> <blockquote><div class="p"><i>&lsquo;On n'est jamais mieux servi que par soi-même <a href="http://forum.wordreference.com/showthread.php?t=263500">&hellip;</a>&rsquo;</i></div></blockquote> </div>
<div class="p"> I added a <tt>Blog</tt> module to <a href="https://github.com/smondet/dibrawi">Dibrawi</a>'s helper interface for <a href="http://martin.jambon.free.fr/camlmix/">Camlmix</a>. Let's say <i>Dibrawi</i> is a Wiki engine <i>under heavy development</i>, based on the <a href="http://seb.mondet.org/bracetax/">Bracetax</a> syntax, bibliography management with <a href="http://sebib.forge.ocamlcore.org/">Sebib</a>, and other stuff (e.g. an address book). It has a <i>wiki</i> default running mode, which only converts the wiki pages, the bibliography, and the address book to HTML. The <i>wiki</i> mode is fast and <i>seems</i> secure<small class="notebegin">(</small><small class="note">or at least it is more secure than any other wiki engine I know&nbsp;&hellip;</small><small class="noteend">)</small>. On the other hand, each page can be <i>preprocessed</i> separately (locally, on command line) while activating OCaml code (<i>Camlmix</i>). This code will be compiled and run to generate whatever the user wants (like a <a href="http://seb.mondet.org">web site</a>, or a <a href="http://seb.mondet.org/CV_SebastienMONDET.pdf">PDF</a>). In <i>wiki</i> mode, the OCaml code is just displayed as <tt>code</tt> or ignored. </div>
<div class="p"> Henceforth, this new blog engine is a nice occasion to start showing some of the ideas behind <i>Dibrawi</i>. With some OCaml code one can quickly and easily generate a static blog (which uses <a href="http://disqus.com/">Disqus</a> as comment system). The bunch of HTML files together with the RSS feeds can be uploaded to any hosting facility (like <a href="http://github.com">GitHub</a>&nbsp;<tt>;&#150;)</tt>). </div>
<div class="p"> The idea is to play with the <a href="https://github.com/smondet/dibrawi/blob/f38296ac3b6b7fa168ac38c4baec7e0e24b387ba/src/lib/dibrawi_mix.ml#L782"><tt>Blog</tt> module</a>'s functions (and the rest of the <tt>dibrawi</tt> library) to generate a full blog. Here is a full example:
<ul>
<li> <a href="https://github.com/smondet/dibrawi/blob/master/doc/examples/Blog.brtx"><b>The file <tt>Blog.brtx</tt></b></a>: We see the <i>tags</i> <tt>{mix:code}</tt>, <tt>{mix:ignore}</tt> and <tt>{mix:end}</tt> which are the <i>main</i> escape commands to put OCaml code within <i>Dibrawi</i> (replacing the &ldquo;<tt>##</tt>&rdquo; family in Camlmix). </li>
<li> <a href="http://seb.mondet.org/dibrawi/wiki/examples/Blog.html"><b>The <i>wiki</i> mode version</b></a> displays the OCaml code which used <tt>{mix:code}</tt>. </li>
<li> <a href="http://seb.mondet.org/dibrawi/blog/"><b>The blog</b></a> (HTML and RSS files) is generated by the code at the end of the source. </li>
</ul>
</div>
<div class="p"> Once the framework is set up, each new blog post is just some text enclosed between <tt>blog#new_post</tt> and <tt>blog#end_post</tt> calls, e.g.: <pre>
{mix:code} blog#new_post
~title:"Anyweb, Document Source Code The Way You Like"
~date:"Tue, 19 Apr 2011 21:26:42 +0200"
~tags:[ "hack_of_the_day"; "anyweb"; "coq"; "ocaml" ]
"anyweb-document-source-code-the-way-you-like"
{mix:end}
I was playing with Adam Chlipala's
{q|{link http://adam.chlipala.net/cpdt/ |CPDT}} book
and I wanted to take notes on some notations.
I also wanted to do it in a
# Quite a lot of text ...
{mix:code} blog#end_post {mix:end}
</pre> </div>
<div class="p"> Each time, generating the blog is as simple as calling <tt>dbw</tt> with the <tt>run</tt> command: <pre>
dbw run path/to/Blog.brtx
</pre> and that's all for today folks! </div>
http://seb.mondet.org/blog/post/third-post-new-blog-engine.html
http://seb.mondet.org/blog/post/third-post-new-blog-engine.htmlTue, 26 Apr 2011 09:28:20 +0200Back From IFIP SEC 2011<div class="p"> Back from 3 days of conference in the beautiful little town of <a href="http://en.wikipedia.org/wiki/Lucerne">Lucerne</a>, in Switzerland, where was the <a href="http://sec2011.org/">IFIP SEC 2011</a> conference. </div>
<div class="p"> Among the 24 papers presented, at least 2 where based on OCaml work. One paper (Demay et al.) uses and extends <a href="http://frama-c.com/">Frama-C</a> to analyse and instrument C code; the other (ours) generates code from an OCaml program and proves security properties on it thanks to <a href="http://why.lri.fr/">Why</a> and <a href="http://alt-ergo.lri.fr/">Alt-Ergo</a>. </div>
<div class="p"> There were funny hacker-style papers as well as boring ones (and a few which I did not understand&nbsp;&hellip;). I have put my <a href="http://smondet.at.ifi.uio.no/resources/report_ifipsec11.html">notes on the conference</a> on-line (of course made with <a href="https://github.com/smondet/dibrawi">Dibrawi</a>). If you have comments, questions, or if you recognise yourself and do not approve what I have written, do not hesitate to drop me a line. </div>
http://seb.mondet.org/blog/post/ifip-sec-2011.html
http://seb.mondet.org/blog/post/ifip-sec-2011.htmlThu, 16 Jun 2011 14:45:32 +0200Coq Programming with Subsets<div class="p">A discussion about learning Coq for programming purposes (with OCaml extraction) and a <i>first</i> dissected Coq development investigating &ldquo;subsets&rdquo; (the <tt>sig</tt> type)&nbsp;&hellip; <a href="http://seb.mondet.org/blog/post/coqtests-01-subsets.html">Read more</a>.</div>
http://seb.mondet.org/blog/post/coqtests-01-subsets.html
http://seb.mondet.org/blog/post/coqtests-01-subsets.htmlWed, 17 Aug 2011 21:01:56 +0200Programming Decisions with Coq's Sumbools<div class="p">A dissected Coq development with some experiments about the <tt>sumbool</tt> type&nbsp;&hellip; <a href="http://seb.mondet.org/blog/post/coqtests-02-sumbools.html">Read more</a>.</div>
http://seb.mondet.org/blog/post/coqtests-02-sumbools.html
http://seb.mondet.org/blog/post/coqtests-02-sumbools.htmlWed, 31 Aug 2011 09:59:59 +0200Coq's sumor Type<div class="p">Trying to use the <tt>sumor</tt> type, (Coq development)&nbsp;&hellip; <a href="http://seb.mondet.org/blog/post/coqtests-03-sumors.html">Read more</a>.</div>
http://seb.mondet.org/blog/post/coqtests-03-sumors.html
http://seb.mondet.org/blog/post/coqtests-03-sumors.htmlSat, 10 Dec 2011 12:46:27 -0500