<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hello,</div><div><br></div><div>Here is the latest Caml Weekly News, for the week of July 1 to 8, 2008.</div><div><br></div><div>1) ooauth 0.1</div><div>2) ethreads relesase</div><div>3) Logic File System</div><div>4) Newbie question: OCaml equivalent of Haskell's show?</div><div>5) Bisect 1.0 alpha</div><div><br></div><div>========================================================================</div><div>1) ooauth 0.1</div><div>Archive: <<a href="http://groups.google.com/group/fa.caml/browse_thread/thread/a276b47d2a7301f6">http://groups.google.com/group/fa.caml/browse_thread/thread/a276b47d2a7301f6</a>></div><div>------------------------------------------------------------------------</div><div>** Jake Donham announced:</div><div><br></div><div>Skydeck is pleased to announce ooauth, an implementation of the OAuth</div><div>1.0 protocol for OCaml, as well as an OCaml binding to our web API</div><div>(providing access to your cell phone call log). More at</div><div><br></div><div> <<a href="http://skydeck.com/blog/announcements/skydeck-api-and-oauth-for-ocaml/">http://skydeck.com/blog/announcements/skydeck-api-and-oauth-for-ocaml/</a>></div><div><br></div><div>The OAuth library provides both the "service provider" and "consumer"</div><div>sides of OAuth, so you can use it to build a web API of your own, or</div><div>to access one of the increasing number of APIs supporting OAuth (such</div><div>as the Google data APIs). More at</div><div><br></div><div> <<a href="http://oauth.net/">http://oauth.net/</a>></div><div><br></div><div>If you'd like to try Skydeck (and have a cell phone with a major</div><div>American carrier), drop me an email (of course you don't need a</div><div>Skydeck account to use the OAuth library).</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div><div>========================================================================</div><div>2) ethreads relesase</div><div>Archive: <<a href="http://groups.google.com/group/fa.caml/browse_thread/thread/a70e7429bb382275">http://groups.google.com/group/fa.caml/browse_thread/thread/a70e7429bb382275</a>></div><div>------------------------------------------------------------------------</div><div>** Satoshi Ogasawara announced:</div><div><br></div><div>I'm pleased to announce a new release of 'ethreads', small codes for</div><div>multi-thread programming. This library has</div><div>- extended Threads.Event module.</div><div>- threadless ivar and mvar, inter-thread shared variable.</div><div>- mailbox(queue), broadcast channel, timeout, meta-RPC.</div><div>I believe these features are necessary for channel passing style multi-thread </div><div>programming with OCaml.</div><div>More at: </div><div>Project Home Page: <<a href="http://forge.ocamlcore.org/projects/ethread/">http://forge.ocamlcore.org/projects/ethread/</a>></div><div>Signatures : <<a href="http://www.itpl.co.jp/ethreads/">http://www.itpl.co.jp/ethreads/</a>></div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div><div>========================================================================</div><div>3) Logic File System</div><div>Archive: <<a href="http://groups.google.com/group/fa.caml/browse_thread/thread/d190955371ca664f">http://groups.google.com/group/fa.caml/browse_thread/thread/d190955371ca664f</a>></div><div>------------------------------------------------------------------------</div><div>** Yoann Padioleau announced:</div><div><br></div><div>I am pleased to announce the release of the Logic File System (LFS).</div><div>LFS is a very expressive file system coded in OCaml.</div><div>LFS enables the user to access his files through an</div><div>additionnal mountpoint, /lfs, where powerful logic queries can be</div><div>issued and navigation can be done through different dimensions, like</div><div>date, size, or extension. For instance, LFS allows the user to perform</div><div>the following commands in the shell:</div><div><br></div><div>$ cd /lfs/ext:mp3|ext:ogg/year:1973/genre:Disco/</div><div>$ ls</div><div>artist:BeeGees/ artist:DonnaSummer/ artist:Chic/ ...</div><div>$ cd /lfs/ext:ml|ext:mli/.ext</div><div>$ ls</div><div>list.ml list.mli array.ml array.mli ...</div><div><br></div><div><br></div><div>It uses FUSE (and ocamlfuse). LFS just acts like an additionnal way to</div><div>access your files.</div><div>No need to migrate your data to LFS.</div><div><br></div><div><br></div><div>Homepage:</div><div><<a href="http://aryx.kicks-ass.org/~pad/wiki/wiki-LFS/doku.php">http://aryx.kicks-ass.org/~pad/wiki/wiki-LFS/doku.php</a>></div><div>Tar/GZ:</div><div><<a href="http://aryx.kicks-ass.org/~pad/software/project-lfs/lfs-0.5.tgz">http://aryx.kicks-ass.org/~pad/software/project-lfs/lfs-0.5.tgz</a>></div><div>Quick install guide:</div><div><<a href="http://aryx.kicks-ass.org/~pad/wiki/wiki-LFS/doku.php?id=quickguide">http://aryx.kicks-ass.org/~pad/wiki/wiki-LFS/doku.php?id=quickguide</a>></div><div>Tutorial:</div><div> <<a href="http://aryx.kicks-ass.org/~pad/wiki/wiki-LFS/doku.php?id=syntax">http://aryx.kicks-ass.org/~pad/wiki/wiki-LFS/doku.php?id=syntax</a>></div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div><div>========================================================================</div><div>4) Newbie question: OCaml equivalent of Haskell's show?</div><div>Archive: <<a href="http://groups.google.com/group/fa.caml/browse_thread/thread/de74ef19c7864194">http://groups.google.com/group/fa.caml/browse_thread/thread/de74ef19c7864194</a>></div><div>------------------------------------------------------------------------</div><div>** Antony Courtney asked and Richard Jones answered:</div><div><br></div><div>> I'm an experienced Haskell hacker trying OCaml for the first time. </div><div>> </div><div>> One thing I am desperately searching for but have been unable to find </div><div>> is some direct runtime access to the string representation of </div><div>> arbitrary OCaml values. I have written a little option pricer that </div><div>> constructs a </div><div>> float option array array </div><div>> in a function. I've got a little buglet in my function so I'd like to </div><div>> print the intermediate states of this value from inside the function. </div><div>> How do I do that, short of writing my own recursive pretty printer / </div><div>> formatter? An OCaml form of the Haskell Show type class would be </div><div>> great, but a hack to provide programmatic access to the polymorphic </div><div>> pretty printer that obviously already exists in the OCaml toplevel </div><div>> would be fine. </div><div>> </div><div>> I've scoured the standard library docs, manual, tutorials and a few </div><div>> books, looked at the FAQ and am amazed that I haven't found the answer </div><div>> to this. I am hopefully just missing something obvious; would be </div><div>> grateful if someone could point me towards the answer!</div><div><br></div><div>Note that OCaml doesn't carry very much information at runtime about </div><div>what is represented in a value. However there are various generic </div><div>printers around. Probably your best bet for a quick and dirty hack is </div><div>to use the 'Std.dump' function in extlib </div><div>(<<a href="http://code.google.com/p/ocaml-extlib/">http://code.google.com/p/ocaml-extlib/</a>>). This can turn anything into </div><div>a string, and tries to produce something which looks similar to an </div><div>OCaml toplevel value. </div><div><br></div><div>Documentation for Std.dump: </div><div> <<a href="http://ocaml-extlib.googlecode.com/svn/doc/apiref/Std.html">http://ocaml-extlib.googlecode.com/svn/doc/apiref/Std.html</a>> </div><div><br></div><div>If you want to go further than this and have OCaml write a pretty- </div><div>printer for your types, then you'll want to look at one of the </div><div>following projects (and probably others ...) </div><div><br></div><div> <<a href="http://www.ocaml.info/home/ocaml_sources.html">http://www.ocaml.info/home/ocaml_sources.html</a>> </div><div> <<a href="http://code.google.com/p/deriving/">http://code.google.com/p/deriving/</a>> </div><div> <<a href="http://tools.assembla.com/tywith/wiki">http://tools.assembla.com/tywith/wiki</a>> </div><div><br></div><div>Another alternative is to run your code in the OCaml toplevel. </div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div><div>** Jon Harrop also answered:</div><div><br></div><div>> One thing I am desperately searching for but have been unable to find</div><div>> is some direct runtime access to the string representation of</div><div>> arbitrary OCaml values.</div><div><br></div><div>OCaml has no run-time type information, no structural pretty printers in </div><div>compiled code and no type classes to help you implement your own in source </div><div>code.</div><div><br></div><div>> I have written a little option pricer that constructs a</div><div>> float option array array</div><div>> in a function. I've got a little buglet in my function so I'd like to</div><div>> print the intermediate states of this value from inside the function.</div><div>> How do I do that, short of writing my own recursive pretty printer /</div><div>> formatter?</div><div><br></div><div>You basically have two choices:</div><div><br></div><div>.. Run in the top-level and get the value you require as the result of </div><div>evaluating an expression (e.g. by raising an exception, or by setting a </div><div>mutable).</div><div><br></div><div>.. Write your own print function(s) and call them.</div><div><br></div><div>The benefit of the latter is, of course, that it works from compiled code.</div><div><br></div><div>> An OCaml form of the Haskell Show type class would be great,</div><div><br></div><div>IMHO, type classes are great for some things but pretty printing is not one of </div><div>them.</div><div><br></div><div>Start with a function to print a list with an arbitrary separator:</div><div><br></div><div># open Format;;</div><div># let rec fprintfs sep f ff = function</div><div> | [] -> ()</div><div> | [h] -> fprintf ff "%a" f h</div><div> | h::t -> fprintf ff "%a%a%a" f h sep () (fprintfs sep f) t;;</div><div>val fprintfs :</div><div> (Format.formatter -> unit -> unit) -></div><div> (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a list -> unit =</div><div> <fun></div><div><br></div><div>For example, we can now write a function to pretty print a list in Mathematica </div><div>notation:</div><div><br></div><div># let fprintf_mma ff list =</div><div> let sep ff () = fprintf ff ",@ " in</div><div> let int ff = fprintf ff "%d" in</div><div> fprintf ff "{@[%a@]}" (fprintfs sep int) list;;</div><div>val fprintf_mma : Format.formatter -> int list -> unit = <fun></div><div><br></div><div># fprintf std_formatter "%a\n" fprintf_mma (Array.to_list(Array.init 100 (fun </div><div>n -> n)));;</div><div>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,</div><div>21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,</div><div>40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,</div><div>59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,</div><div>78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,</div><div>97, 98, 99}</div><div>- : unit = ()</div><div><br></div><div>Note the automatically-aligned wrapping thanks to OCaml's pretty </div><div>printing "Format" module and the use of "@[", "@ " and "@]" in my code. This </div><div>also works from compiled code and is an excellent way to print indented </div><div>source code (e.g. when generating other languages).</div><div><br></div><div>To pretty print a generic array:</div><div><br></div><div># let fprintf_array f ff array =</div><div> let sep ff () = fprintf ff ";@ " in</div><div> fprintf ff "[|@[%a@]|]" (fprintfs sep f) (Array.to_list array);;</div><div>val fprintf_array :</div><div> (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a array -> unit =</div><div> <fun></div><div><br></div><div>To print an option:</div><div><br></div><div># let rec fprintf_opt f ff = function</div><div> | None -> fprintf ff "None"</div><div> | Some x -> fprintf ff "Some %a" f x;;</div><div>val fprintf_opt :</div><div> (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a option -> unit =</div><div> <fun></div><div><br></div><div>Now you can print your array of arrays of float options:</div><div><br></div><div># let print ff xss =</div><div> let float ff = fprintf ff "%g" in</div><div> fprintf_array (fprintf_array (fprintf_opt float)) ff xss;;</div><div>val print : Format.formatter -> float option array array -> unit = <fun></div><div><br></div><div># fprintf std_formatter "%a\n" print</div><div> [|[|Some 3.; None; None|]; [|None; Some 5.; None|]; [|Some 1.|]|];;</div><div>[|[|Some 3; None; None|]; [|None; Some 5; None|]; [|Some 1|]|]</div><div>- : unit = ()</div><div><br></div><div>> but a hack to provide programmatic access to the polymorphic </div><div>> pretty printer that obviously already exists in the OCaml toplevel</div><div>> would be fine.</div><div><br></div><div>In addition to Richard's suggestions, you might look at generating OCaml </div><div>expressions using camlp4 and then printing those instead. Just an idea (I've </div><div>never tried it).</div><div><br></div><div>> I've scoured the standard library docs, manual, tutorials and a few</div><div>> books, looked at the FAQ and am amazed that I haven't found the answer</div><div>> to this. I am hopefully just missing something obvious; would be</div><div>> grateful if someone could point me towards the answer!</div><div><br></div><div>Surprisingly, structural printing is something that OCamlers rarely do. As </div><div>part of my evolution as a programmer I had migrated everything from C++ and </div><div>Mathematica to OCaml a few years ago but I am actually about to move a little </div><div>parsing-related project from OCaml to F# simply because its built-in pretty </div><div>printers make life so much easier.</div><div><br></div><div>Anyway, I shall write an OCaml Journal article about OCaml's </div><div>wonderful "Format" module. Incidentally, the OCaml Journal has recovered from </div><div>a lull in Q1 and has really started to pick up now. So I still think there is </div><div>plenty of opportunity for budding authors to write OCaml books!</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div><div>========================================================================</div><div>5) Bisect 1.0 alpha</div><div>Archive: <<a href="http://groups.google.com/group/fa.caml/browse_thread/thread/542554fe46aca51a">http://groups.google.com/group/fa.caml/browse_thread/thread/542554fe46aca51a</a>></div><div>------------------------------------------------------------------------</div><div>** Xavier Clerc announced:</div><div><br></div><div>This post announces the 1.0 alpha version of Bisect.</div><div>Bisect is a coverage tool for the Objective Caml language.</div><div>Home page: <<a href="http://bisect.x9c.fr">http://bisect.x9c.fr</a>></div><div><br></div><div>Features:</div><div> - lightweight tool</div><div> - camlp4-based instrumentation of source files</div><div> - HTML-based report with replica of original source code annotated with coverage information</div><div> - per-file and application-wide statistics</div><div><br></div><div>Dependencies:</div><div> - Objective Caml 3.10.2</div><div> - Unix module</div><div><br></div><div>Planned features:</div><div> - other report formats (framed HTML, XML, bare text)</div><div> - thread support</div><div> - some nice features borrowed from HPC </div><div>(<<a href="http://projects.unsafeperformio.com/hpc/">http://projects.unsafeperformio.com/hpc/</a>>)</div><div><br></div><div><br></div><div>This is my very first non-trivial camlp4-based application, and would be glad</div><div>to hear comment and suggestions about Bisect, and the way it could be</div><div>enhanced.</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div><div>========================================================================</div><div>Using folding to read the cwn in vim 6+</div><div>------------------------------------------------------------------------</div><div>Here is a quick trick to help you read this CWN if you are viewing it using</div><div>vim (version 6 or greater).</div><div><br></div><div>:set foldmethod=expr</div><div>:set foldexpr=getline(v:lnum)=~'^=\\{78}$'?'<1':1</div><div>zM</div><div>If you know of a better way, please let me know.</div><div><br></div><div>========================================================================</div><div>Old cwn</div><div>------------------------------------------------------------------------</div><div><br></div><div>If you happen to miss a CWN, you can send me a message</div><div>(<a href="mailto:alan.schmitt@polytechnique.org">alan.schmitt@polytechnique.org</a>) and I'll mail it to you, or go take a look at</div><div>the archive (<<a href="http://alan.petitepomme.net/cwn/">http://alan.petitepomme.net/cwn/</a>>) or the RSS feed of the</div><div>archives (<<a href="http://alan.petitepomme.net/cwn/cwn.rss">http://alan.petitepomme.net/cwn/cwn.rss</a>>). If you also wish</div><div>to receive it every week by mail, you may subscribe online at</div><div><<a href="http://lists.idyll.org/listinfo/caml-news-weekly/">http://lists.idyll.org/listinfo/caml-news-weekly/</a>> .</div><div><br></div><div>========================================================================</div><div class="AppleMailSignature" id="E12A09DE-ADCF-40D6-B7D4-306ED5CADD30"> <div><br class="khtml-block-placeholder"></div><div>-- </div><div>Alan Schmitt <<a href="http://alan.petitepomme.net/">http://alan.petitepomme.net/</a>></div><div><br class="khtml-block-placeholder"></div><div>The hacker: someone who figured things out and made something cool happen.</div><div> .O.</div><div> ..O</div><div> OOO</div><br class="Apple-interchange-newline"> </div><br></body></html>