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