Previous week Up Next week

Hello

Here is the latest Caml Weekly News, for the week of 02 to 09 March, 2004.

  1. Use of abstract type "inet_addr"
  2. Development versions: ocamlconf, ASPCC
  3. Computational Logic in OCaml
  4. Job: OCAML/Java/XML Research Sofware Engineer
  5. Announceing rmwd
  6. ocaml/amd64 native compiler on openbsd
  7. Announce: Nativize 0.1

Use of abstract type "inet_addr"

Vasili Galchin asked and Christophe Troestler suggested:
> I want to use type "inet_addr"

The following is really well written and should answer all your
questions: http://cristal.inria.fr/~remy/poly/system/ (cf. in
particular chapter 6).
    
Henri Dubois-Ferriere asked and Didier Remy answered:
> some time back, i had offered to the authors to translate the
> "unix programming in ocaml" book
> (http://cristal.inria.fr/~remy/poly/system/camlunix/index.html)
> into english, since (i think) it would fille a gap in ocaml documentation,
> but i never got any answer from them.

Hi Henri,

Sorry for not responding at that time, but I had preciously kept
your original Email and I intended to recontact you at some point.

This document was originally written by Xavier Leroy for a course he taught
at the École Normale Supérieure years ago.  I translated them from
Caml-Light to OCaml last year since I've been using them myself for a course
I taught at École Polytechnique.  I am currently revising them and adding
some new material while I am repeating the course this year.

I have no doubt that there is a potential audience for this book that is
much broader than just a the few students in my class.  This could
encourage people who already know OCaml but who are new to system
programming to learn system programming more smoothly; conversely, they
could also show hackers who are new to OCaml that they can still do their
favorite system hasks in OCaml while taking advantage of high-level
programming. And, as you mention, this could complement the documentation of
the Unix library.

So, translating these notes into English would certainly be profitable to
the community.

If you are still willing to do the translation after I finished the
revision, we can continue discussing it privately.
    

Development versions: ocamlconf, ASPCC

Kenneth Knowles announced:
I have two projects that I haven't polished to a release state, but I'm hoping
someone might be interested in, so I'm offering access via darcs
(http://www.abridgegame.org/darcs)

(1) ocamlconf
Ocamlconf is like autoconf but much simpler, utterly ocaml-centric, and
dependent on findlib.

You can get it via the command
        'darcs get http://kefka.frap.net:8080/~kenn/repos/ocamlconf'

What it is/does:
*       An autoconf-like tool but using ocaml scripts instead of m4
*       It uses the ocaml toplevel instead of bytecode for cross-version
        compatability
*       Outputs a makefile and a simple config.ml
*       It is _extremely_ simple to use, especially if your projects are 100% ocaml,
        like mine.  (A configure.ml comparable to a configure.ac might be 100
        lines for a complex project)

Why I didn't use autotools/ocamlmakefile/...:
*       autotools are pretty C centric, and more of a pain than necessary for
        an ocaml project which already limits its audience to more-or-less modern
        users.  GNU must support very arcane and archaic setups, but ocamlconf aims
        to suport "anything with ocaml"
*       anyone building an ocaml package with have the toplevel already
*       OcamlMakefile is awkward with multiple targets (such as suites of utilities)
        and I'd rather write (or depend on) a simple ocaml script than a complex
        Makefile
*       And of course, I did it to see if I could make something simple and useful
        for myself - I've succeeded, as it is what I use for 100% of my ocaml
        projects

(2) ASPCC
ASPCC started as a little project to robustly parse VbScript, for practice.
Then with the abstract syntax tree I tried to output equivalent PHP scripts.  I
got pretty far on that, and decided I needed to run the VbScript in order to do
unit-test comparisons between it and the PHP.  Here is what it is now:

You can get it via the command
        'darcs get http://kefka.frap.net:8080/~kenn/repos/aspcc'

*       A naively simple ASP interpreter that still appears to be more than
        competitive in speed with MS ASP, but needs more DB support to run
        real-world apps.  It does, however, support all VbScript syntax.

*       Support for running .asp files under Apache.  No mod_caml support yet, but
        it runs as a CGI and is not at a point

*       An incomplete bytecode compiler and VM.  I made up a new bytecode instead of
        using ocaml or Java because VbScript has really really weird semantics
        sometimes.  Also I want to try my hand at a little virtual machine for fun.

Again, the disclaimers:  I hate VbScript, but I program it because my company
has a huge ASP codebase, and I love the people here; they are just a little
change-wary.  There are other VbScript / ASP solutions, but all of them are
incomplete in different ways, have different focuses, and are written in
languages that I'm not really interested in using.
    
Issac Trotts asked and Kenneth Knowles answered:
> I guess you mean David's Advanced Revision Control System.

DARCS is very nice; if you are familiar with Tom Lord's arch, consider a similar
design, but many fewer commands and simpler usage - this may or may not be ideal
for you.  I also gain a lot of confidence from DARCS being written in Haskell.

> There is no Debian package for this,
> though it looks like a useful program.

From the DARCS webpage:
----------------------

Debian users

If you use debian, you can install darcs via apt. For woody, add the following
lines to your sources.list:

deb http://http.abridgegame.org/debian/ woody/
deb-src http://http.abridgegame.org/debian/ woody/

If you are running woody, and want to compile darcs yourself, you may want to
add the following line as well, which provides a ghc compiler that is
sufficiently recent to compile darcs:

deb http://www.syntaxpolice.org/haskell-experimental/ stable/

If you are running sid (Debian unstable), you can instead use the following
lines:

deb http://http.abridgegame.org/debian/ unstable/
deb-src http://http.abridgegame.org/debian/ unstable/

> I wonder if Darcs could be modified to explicitly keep track of changes
> to the ASTs of OCaml source files...

Now this sounds interesting!  Someone very ambitious could invent a source
control item with plugins for parsing different languages, and diffing the
trees.

> Could it output an OCaml script instead of a makefile?  It would
> probably be easier to read, debug, and modify.

I phrased this badly.  What you want, is what it does, I think.  I should have
said that it "outputs a configure script, which when run outputs a makefile and
config.ml"

I will quickly explain all of what it does.

(1)     You write configure.ml, somewhat analogous to configure.ac
(2)     You run ocamlconf, it creates a configure script
----
(3) The end user/you run the configure script - it outputs a makefile and/or
    configuration summary ocaml file.
(4) make && make install

Every stage is easy to debug - your configure.ml script is a simple ocaml
script.  The configure script (actually configure.mlc, for technical reasons,
and the configure script is a shell wrapper around `ocaml configure.mlc`) is
also plain text ocaml, but with additional code copied into it.  And even the
makefile is about as simple as possible for your project, so hopefully bugs in
ocamlconf will easily be discovered.
    
Kenneth Knowles then answered several other questions:
> > So the produced configure script is an OCaml program that needs the
> > ocaml environment to run?
>
> We could solve this problem by bundling a simple sh script to check
> whether OCaml is installed, and maybe get it if not.

It already does this, sorry about being so terrible about the details!  (I kind
of thought of that as an implementation detail, but now I see it was important
to tell people).  'configure' is a sh script, and 'configure.mlc' is the ml
file.  I used a funny suffix so it wouldn't conflict with configure.ml -
probably I should just invent a name like configure_out.ml

The sh script is a little bare, because it has only been used on 3 or 4 systems,
and it doesn't really have to do much.

> Hi Kenneth,
>    Any chance that you could make a more standard distribution of ocamlconf,
> like say a gzipped tarball that the darcs deprived can use?
> -- Brian

Sure; I didn't do this because I didn't want to deceive anyone about that they
were getting :-)  Now that I see the level of interest, I'll package it up into
a release.

Meanwhile, there is a tarball of the ocamlconf directory:
http://kefka.frap.net:8080/~kenn/repos/ocamlconf.tar.gz
    

Computational Logic in OCaml

Olivier Grisel asked and Jean-Christophe Filliatre answered:
> I plan to write some implementation of classical Inductive Logic
> Programming strategies in OCaml and I would like to know if there exists
> ocaml libraries for computational logic (first order logic) available
> under a free software license.
> 
> I would also welcome thanksfully any advice or design guideline on data
> structures for objects such as Horn clauses (datalog or with functors),
> variable bindings and ideas to efficiently implement opertations such as
> resolution and theta-subsumption test.
> 
> So far I have found an interesting implemantation of Hantao Zhang's
> linear Robinson unification algorithm
> (http://abaababa.ouvaton.org/caml/unify.ml) and graph based algorithms
> for efficient theta-subsumtion test (http://citeseer.nj.nec.com/111654.html)

You may be interested in John Harrison's Theorem Proving Examples:

  http://www.cl.cam.ac.uk/users/jrh/atp/index.html
    

Job: OCAML/Java/XML Research Sofware Engineer

Guillaume Lebleu announced:
Brixlogic (http://www.brixlogic.com) currently has an open OCAML/Java/XML Research
Software Engineer position in France.

The Research Software Engineer will participate in a research project on
strongly typed visual XML processing languages. In this position, he/she
will be interfacing with research scientists at leading French software
research labs and with experts in financial and insurance XML web services.

The ideal candidate will:
- Have a MSc or PhD or equivalent in Mathematics, Computer Science, or
similar field from a leading University
- Be proficient in OCAML, Java, XML and related specifications (XML schema
in particular)
- Have interest in visual languages and domain specific languages
- Have strong mathematical background (type thoery, abstract algebra, etc.)

For more information, please send your resume to Guillaume Lebleu, Director
Product Management (gl@brixlogic.com) before March 12th.


About Brixlogic:

Brixlogic (http://www.brixlogic.com) is a provider of an XML-centric application
platform for the financial services and insurance industries. Brixlogic's
software enables complex, industry-standard financial web services that
enables financial services and insurance companies to: decrease
time-to-market of new products and services, increase customer care by
providing a unified real-time multichannel customer experience, and automate
external and internal business processes for increased productivity, and
faster policy and regulation compliance.
    

Announceing rmwd

Eric Stokes announced:
This is to announce that we have released the first external version of
a project we've been working on for quite a while.
        Remote Middleware Daemon is a high level identity management
library focused on services and access control, and exposed via both
xdr-rpc, and xml-rpc. It is written entirely in Objective Caml, except for
the trivial xmlrpc interface, which is in perl.

Much more information can be found at

http://ncc.csun.edu/opensource/
    

ocaml/amd64 native compiler on openbsd

Anil Madhavapeddy announced:
I've committed support into OpenBSD ports for the ocaml/amd64 native
compiler.  It will be available in OpenBSD 3.5.

The configure patch at the end of the msg is required to detect the
OpenBSD architectures.  Also, OpenBSD uses BSD nm, and not the binutils
one, but it appears to work fine with ocamlopt, so the test for that is
modified as well.

The only other issue is that the version of gas used in OpenBSD doesnt
support the mergeable section flag, so I just removed it from the assembly
output, without any ill-effects as far as I can tell.

..section .rodata.cst8,"aM",@progbits,8   becomes
..section .rodata.cst8,"a",@progbits

The exceptions fix from ocaml-current was also needed.

--- configure.orig      2003-09-25 09:17:13.000000000 +0100
+++ configure   2004-03-05 15:44:08.000000000 +0000
@@ -537,6 +537,7 @@ case "$host" in
   alpha*-*-freebsd*)            arch=alpha; system=freebsd;;
   alpha*-*-netbsd*)             arch=alpha; system=netbsd;;
   alpha*-*-openbsd*)            arch=alpha; system=openbsd;;
+  amd64-*-openbsd*)            arch=amd64; system=openbsd;;
   sparc*-*-sunos4.*)            arch=sparc; system=sunos;;
   sparc*-*-solaris2.*)          arch=sparc; system=solaris;;
   sparc*-*-*bsd*)               arch=sparc; system=bsd;;
@@ -555,6 +556,7 @@ case "$host" in
   powerpc-*-aix*)               arch=power; model=ppc; system=aix;;
   powerpc-*-linux*)             arch=power; model=ppc; system=elf;;
   powerpc-*-netbsd*)            arch=power; model=ppc; system=bsd;;
+  macppc-*-openbsd*)            arch=power; model=ppc; system=bsd;;
   powerpc-*-rhapsody*)          arch=power; model=ppc; system=rhapsody;;
   powerpc-*-darwin*)            arch=power; model=ppc; system=rhapsody;;
   arm*-*-linux*)                arch=arm; system=linux;;
@@ -629,8 +631,11 @@ esac
 cc_profile='-pg'
 case "$arch,$model,$system" in
   alpha,*,digital) profiling='prof';;
+  alpha,*,openbsd) profiling='prof';;
   i386,*,linux_elf) profiling='prof';;
   i386,*,bsd_elf) profiling='prof';;
+  amd64,*,openbsd) profiling='prof';;
+  sparc,*,bsd) profiling='prof';;
   sparc,*,solaris)
     profiling='prof'
     case "$nativecc" in gcc*) ;; *) cc_profile='-xpg';; esac;;
@@ -654,8 +659,8 @@ if test "$arch" != "none"; then
         echo "$d/objcopy does not support option --redefine-sym, discarded"
         continue;
       fi
-      if test `$d/nm --version | grep -s -c 'GNU nm'` -eq 0; then
-        echo "$d/nm is not from GNU binutils, discarded"
+      if test `$d/nm --version 2>&1|grep -E -s -c 'GNU nm|OpenBSD'` -eq 0; then
+        echo "$d/nm is not from GNU binutils or OpenBSD, discarded"
         continue;
       fi
       binutils_objcopy="$d/objcopy"
    

Announce: Nativize 0.1

Issac Trotts announced:
Nativize : Compile and run native functions from the toplevel.

http://redwood.ucdavis.edu/~issac/software/nativize-0.1.tar.gz

Introduction
============
  It is useful to be able to easily run native code from the toplevel.
  Nativize makes this possible for functions whose arguments and return
  values can be serialized using the functions in OCaml's Marshal
  module.

Example: running Ackermann's function in the toplevel
=====================================================

# #require "nativize";;
Loading /usr/lib/ocaml/3.07/nativize/nativize.cma
# Nativize.nativize "Ack1" "
  let rec ack m n =
      if m = 0 then n + 1
      else if n = 0 then ack (m - 1) 1
      else ack (m - 1) (ack m (n - 1));;
  " [];;
Please type #load "Ack1.cmo";;
- : unit = ()
# #load "Ack1.cmo";;
# assert(Ack1.ack 5 0 = 65533);; (* Wait about 10 seconds. *)
- : unit = ()
# let rec ack m n =
      if m = 0 then n + 1
      else if n = 0 then ack (m - 1) 1
      else ack (m - 1) (ack m (n - 1));;
# ack 5 0;;  (* Wait a good while longer. *)
    

Using folding to read the cwn in vim 6+

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.


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