Previous week Up Next week

Hello

Here is the latest Caml Weekly News, for the week of June 16 to 23, 2009.

  1. OCaml Meeting 2009 in Tokyo
  2. All OCaml packages synchronised for OCaml 3.11.0 in Ubuntu Karmic
  3. Inflection lib for ocaml ?
  4. Obj.magic and existential types
  5. Camomile 0.7.2
  6. Other Caml News

OCaml Meeting 2009 in Tokyo

Archive: http://caml.inria.fr/pub/ml-archives/caml-list/2009/06/b2d4360797f291c07400a4408db0d22a.en.html

Jun Furuse announced:
It is my pleasure to announce OCaml Meeting 2009 in Tokyo.

In Japan, we have significant numbers of OCaml users. OCaml has been
used for programming courses in several universities for years. We can
read OCaml related blog posts written by people live in Japan
everyday. We have even several Japanese books about programming in
OCaml. But we have never met together. Now it is the time to meet up!
OCaml Meeting 2009 in Tokyo will be the first OCaml specific
conference in Japan:

   Date:              2009/08/30 (Sorry, it collides with ICFP unfortunately.)
   Place:             the University of Tokyo, Sanjo Conference Hall
   Participation fee: Free!

   The meeting will be partially sponsored by
    - IT Planning, Inc. (http://www.itpl.co.jp/)
    - Jane Street Capital (http://www.janestreet.com)

Its primary objective this time is to kick-start a local OCaml user
community in Japan. Therefore talks will be mainly in Japanese and
OCaml, but we welcome everyone interested in OCaml from everywhere.

Further information will appear at the following sites:

  http://www.cocan.org/events        (in English)
  http://ocaml.jp/?Users%20Meeting   (in Japanese)

For people who need further information, you can contact either me or
Satoshi Ogasawara <ogasawara(a)itpl.co.jp>.

We thank OCaml Meeting organization team of the past two OCaml
Meetings in France, who has kindly permitted us to use the same name,
"OCaml Meeting".
	   

All OCaml packages synchronised for OCaml 3.11.0 in Ubuntu Karmic

Archive: http://caml.inria.fr/pub/ml-archives/caml-list/2009/06/85383174bb1b902c9413a752cb0f8bd0.en.html

David MENTRE announced:
I'm pleased to announce that all OCaml packages made by Debian
developers are now synchronized to OCaml 3.11.0 in Ubuntu Karmic:
  http://bentobako.org/ubuntu-ocaml-status/transition_monitor/ocaml_transition_monitor.html

Moreover, all packages[1] have the same version number in Debian
Unstable and Ubuntu Karmic:
  http://bentobako.org/ubuntu-ocaml-status/raw/compare-unstable-karmic.html

So Ubuntu Karmic, aka 9.10, to be released in October will ship with a
full fledge OCaml 3.11.0! Many thanks to all Debian and Ubuntu
developers involved.

Regarding recently released OCaml 3.11.1, I'm not sure it will be
ready for Karmic but it will be available in Karmic+1 and probably in
a backport or through PPA.

Sincerely yours,
david

[1] Except unison package, but the changes made in 2.27.57-2 revision
should not impact users.
  http://packages.debian.org/changelogs/pool/main/u/unison/current/changelog#versionversion2.27.57-2
	   

Inflection lib for ocaml ?

Archive: http://caml.inria.fr/pub/ml-archives/caml-list/2009/06/8369429f41ab8e92250ad052a13f00aa.en.html

Conglun Yao asked, Pascal Rigaux said, and Sylvain Le Gall added:
> > I'm wondering is there any library in OCaml performing word inflection
> > between singular and plural, like Lingua-EN-Inflect in perl. Or someone is
> > already doing the work?
>
> not really comparable to Lingua-EN-Inflect, but if you want one day to
> have i18n and you are under linux, ngettext is quite powerful.
> cf http://www.gnu.org/software/hello/manual/gettext/Plural-forms.html
>

FYI, a pure OCaml implementation of ngettext, with plural support, can
be found in ocaml-gettext:
http://le-gall.net/sylvain+violaine/ocaml-gettext.html
	   
Richard Jones also suggested:
You should be able to call the perl module directly using
perl4caml.
	   

Obj.magic and existential types

Archive: http://caml.inria.fr/pub/ml-archives/caml-list/2009/06/e95c643956552bdc419820e0a3a81086.en.html

Guillaume Yziquel said:
Please don't scream: I've been using Obj.magic...

But the result is rather interesting. It can record a flow of 
computations, and recompute them only when upstream data has been modified:

> # let (n', n) = Dependent.encapsulate 1;;
> val n' : int Dependent.data = <abstr>
> val n : int Dependent.t = <abstr>
> # let (_, next) = Dependent.encapsulate (fun x -> x + 1);;
> val next : (int -> int) Dependent.t = <abstr>
> # let m = Dependent.apply next n;;
> val m : int Dependent.t = <abstr>
> # Dependent.access m;;
> - : int = 2
> # Dependent.set n' 3;;
> - : unit = ()
> # Dependent.access m;;
> - : int = 4

The piece of code responsible for this behaviour is at the end of the 
message.

I learnt that I could perhaps overcome the use of Obj.magic by using 
existential types. I was advised to read the following post on this topic:

http://caml.inria.fr/pub/ml-archives/caml-list/2004/01/52732867110697f55650778d883ae5e9.en.html

However, I do not really understand how Daniel implemented existential 
types there, and I do not really see how it can be adapted to my code. 
Suggestions welcomed.

Here's the code, rather disorganised at the moment.

All the best,

Guillaume Yziquel.


> type read;;
> type write;;
> 
> type 'a computation = (Obj.t -> 'a) t * Obj.t t
> 
> and ('a, 'b) aux_t = Dependent of
>   ( 'a option ref *
>     'a computation option *
>     Obj.t t list ref)
> 
> and 'a data = ('a, write) aux_t
> and 'a t    = ('a, read)  aux_t;;
> 
> let encapsulate (x : 'a) : ('a data) * ('a t) =
>   let z = Dependent ((ref (Some x)), None, (ref [])) in (z, z);;
> 
> let add_dependency (alpha : 'a t) (beta : 'b t) =
>   let Dependent (_, _, dep) = alpha in
>   dep := ((Obj.magic beta) : Obj.t t)::!dep;;
> 
> let apply (f : ('b -> 'a) t) (x : 'b t) : 'a t =
>   let computation : 'a computation =
>     ((Obj.magic f) : (Obj.t -> 'a) t),
>     ((Obj.magic x) : Obj.t         t) in
>   let f_x : 'a t = Dependent (
>     ((ref None)         : 'a option ref),
>     ((Some computation) : 'a computation option),
>     ((ref [])           : Obj.t t list ref)) in
>   add_dependency f f_x;
>   add_dependency x f_x;
>   f_x;;
> 
> exception Undefined;;
> 
> module rec Aux :
> sig
> 
>   val access : 'a t -> 'a
>   val update : 'a t -> ('b -> 'a) t -> 'b t -> 'a
>   val reset  : 'a t -> unit
> 
> end = struct
> 
>   let rec access y =
>     let Dependent (opt_ref_x, comp_opt, _) = y in
>     match !opt_ref_x with | Some x -> x | None ->
>     begin match comp_opt with
>       | None -> raise Undefined
>       | Some (fun_t, arg_t) -> Aux.update y fun_t arg_t
>     end
> 
>   and update y fun_t arg_t =
>     let Dependent (opt_ref_x, _, dependencies) = y in
>     List.iter Aux.reset !dependencies;
>     let result = (Aux.access fun_t) (Aux.access arg_t) in
>     opt_ref_x := Some result; result
> 
>   and reset z =
>     let Dependent (opt_ref_x, _, dependencies) = z in
>     match !opt_ref_x with
>     | None -> () | Some _ -> begin
>         opt_ref_x := None;
>         List.iter Aux.reset !dependencies
>     end;;
> 
> end;;
> 
> include Aux;;
> 
> exception Flawed_implementation;;
> 
> let set (x : 'a data) (v : 'a) : unit =
>   let Dependent (opt_ref_x, comp_opt, dependencies) = x in
>   match comp_opt with | Some _ -> raise Flawed_implementation | None ->
>   begin List.iter Aux.reset !dependencies;
>         opt_ref_x := Some v
>   end;;
	   
Daniel Bünzli replied:
Not directly responding to your question but you are looking for  
functional reactive programming (frp).

http://erratique.ch/software/react

I rewrote your example below with react (no magic used).

Best,

Daniel

 > ocaml react.cmo
         Objective Caml version 3.11.0

# open React;;
# let n, set_n = S.create 1;;
val n : int React.signal = <abstr>
val set_n : int -> unit = <fun>
# let m = S.map (fun x -> x + 1) n ;;
val m : int React.signal = <abstr>
# S.value m;;
- : int = 2
# set_n 3;;
- : unit = ()
# S.value m;;
- : int = 4
	   
Jake Donham also replied:
You can also find FRP in froc (which is quite similar to React; the
main difference is that it works in browsers):

  http://code.google.com/p/froc/

# open Froc_afp;;
# let n = return 1;;
val n : int Froc_afp.t = <abstr>
# let m = n >>= fun x -> return (x + 1);;
val m : int Froc_afp.t = <abstr>
# read m;;
- : int = 2
# write n 3;;
- : unit = ()
# propagate ();;
- : unit = ()
# read m;;
- : int = 4
	   

Camomile 0.7.2

Archive: http://caml.inria.fr/pub/ml-archives/caml-list/2009/06/1a3f29c3afaf4d714c28573283cd5add.en.html

Yoriyuki Yamagata announced:
I'm happy to announce Camomile 0.7.2, new version of comprehensive
Unicode library for Objective Caml.

Changes are
  - License change:  Add OCaml-style exception clause to LGPL license.
  - Small documentation fix to REAEME:  Add cpp to the list of
necessary GNU tools

This will be a small step to Camomile Next Generation, I hope.

After previous release, several people submitted patches (thanks!).  I
do not have time to incorporate them but are submitted patch-tracker
(including patches sent by email)
  https://sourceforge.net/tracker/?group_id=40603&atid=428418

In addition, a new malinglist for discussion between Camomile users is open
  https://lists.sourceforge.net/lists/listinfo/camomile-users
So, discuss and share tips for using of Camomile.  I also want to hear
who and what software use Camomile.
	   
He later added:
Ahem, I'm too hurry to post the article. It lacks the link to the
package itself.

Camomile is available from

https://sourceforge.net/project/showfiles.php?group_id=40603&package_id=32800&release_id=691358
	   

Other Caml News

From the ocamlcore planet blog:
Thanks to Alp Mestan, we now include in the Caml Weekly News the links to the
recent posts from the ocamlcore planet blog at http://planet.ocamlcore.org/.

New HLVM examples:
  http://forge.ocamlcore.org/forum/forum.php?forum_id=390

FP-Syd #16.:
  http://www.mega-nerd.com/erikd/Blog/FP-Syd/fp-syd-16.html

Finite maps galore: imperative code strikes back:
  http://eigenclass.org/R2/writings/finite-map-benchmarks

Ubuntu 9.10 will ship with OCaml 3.11.0... for now:
  https://bentobako.org/david/blog/index.php?post/2009/06/18/Ubuntu-9.10-will-ship-with-OCaml-3.11.0...-for-now

OCaml Monitor Applet:
  http://forge.ocamlcore.org/projects/omonitor-applet/

The Tree Nursery:
  http://alaska-kamtchatka.blogspot.com/2009/06/tree-nursery.html
			

Old cwn

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.


Alan Schmitt