Previous week   Up   Next week
Hello,

Here is the latest Caml Weekly News, week 17 to 24 June, 2003.

1) ICFP 2003 programming contest
2) OCaml-RSS 0.1
3) lablglut bindings
4) SF Bay Area OCaml get together in July
5) scanf and %2c
6) IMap and ISet
7) ocamlnet-0.96 released
8) PXP 1.1.94 (development version)

==============================================================================
1) ICFP 2003 programming contest
------------------------------------------------------------------------------
** Xavier Leroy announced:

Here is the official contest announcement from John Hughes:

---

There are just ten days to go to the sixth ICFP Programming Contest!
Starting at midnight on Saturday morning, June 28th, you can prove
once again that your favourite programming language is "the
programming tool of choice for discriminating hackers!"

Don't miss this opportunity -- check out the contest web site at

        http://icfpcontest.org

for details -- and the tiniest little hint of this year's problem.

John Hughes

==============================================================================
2) OCaml-RSS 0.1
------------------------------------------------------------------------------
** Maxence Guesdon announced:

I'm pleased to announce the first release of OCaml-RSS (0.1).
This library provides functions to parse and print RSS 2.0 files
(and tries to parse RDF files).

There is still some work to do (add missing RSS 2.0 fields, add some
convenient functions), but it can already be used.

You can find it here:
http://www.nongnu.org/ocamlrss/

This library is used in MyRSS, not released yet but a demo is available:
http://www.nongnu.org/myrss/

==============================================================================
3) lablglut bindings
------------------------------------------------------------------------------
** Issac Trotts said:

lablglut-1.2.3 is up at

   http://redwood.ucdavis.edu/~issac/lablglut-1.2.3.tar.gz   

Please update any lablglut links to point to this new location.

==============================================================================
4) SF Bay Area OCaml get together in July
------------------------------------------------------------------------------
** Chris Hecker proposed:
** http://caml.inria.fr/archives/200306/msg00317.html

I was reminded that I dropped the ball on putting some kind of
meeting/dinner for San Francisco ocaml programmers a couple years back.  I,
uh, got busy.  :)

Anyway, let's ressurect the plan and do it.  Nothing fancy, just a casual
meeting.

To attempt to solve the n-body problem, please reply to me privately if
you're interested in attending _WITH_ what dates in the evening (say,
7pm-9pm-ish) you can make it to Berkeley/Oakland during the week of July
14th - 18th.  Also include what kind of food you will _not_ eat if we meet
at a restaurant.  An incredibly sophisticated program will grind over the
data, producing the perfect meeting time and place.

** There are some other places where meetings were proposed:
** Colorado:
   http://caml.inria.fr/archives/200306/msg00319.html
** Great North Wood (Minneapolis/St Paul area)
   http://caml.inria.fr/archives/200306/msg00322.html
** North Carolina (Raleigh/Durham/RTP)
   http://caml.inria.fr/archives/200306/msg00325.html
** Milwaukee
   http://caml.inria.fr/archives/200306/msg00333.html
** Seattle
   http://caml.inria.fr/archives/200306/msg00332.html

==============================================================================
5) scanf and %2c
------------------------------------------------------------------------------
** Alan Schmitt asked and Pierre Weis lectured:

> As I needed to parse some string representing time (of the form hh:mm),
> I decided to use scanf. The correct code to do it is:
> # let time_parse s =
>   Scanf.sscanf s "%2s:%2s" (fun a b -> a,b)
>   ;;
> val time_parse : string -> string * string = <fun>

Just to implement stricter parsing rules (and BTW to show scanf
capabilities), I will elaborate a bit on this ``correct'' code.

To ensure that hh and mm are indeed decimal digits, we could write:

# let scan_date s = Scanf.sscanf s "%2d:%2d";;
val scan_date : string -> (int -> int -> 'a) -> 'a = <fun>

This way, the fields hh and mm are parsed and returned as integers as
they are supposed to be.

So far so good, but this is not precise enough, since (small) negative
hours are still accepted:

# scan_date "-2:12" (fun hh mm -> hh, mm);;
- : int * int = (-2, 12)

That's why I usually use:

# let scan_date s = Scanf.sscanf s "%2[0-9]:%2[0-9]";;
val scan_date : string -> (string -> string -> 'a) -> 'a = <fun>

# scan_date "-2:12" (fun x y -> x, y);;
Exception: Scanf.Scan_failure "scanf: bad input at char number 1: -".

Then, you may argue that we still parse dates like 99:99 which are
meaningless. Scanning the characters one at a time, we could be more
precise and reject a large class of those erroneous dates:

# let scan_date s = Scanf.sscanf s "%1[0-2]%1[0-9]:%1[0-5]%1[0-9]";;
val scan_date : string -> (string -> string -> string -> string -> 'a)
-> 'a = <fun>

If minutes are now appropriately handled, we still accept to parse hours
that are greater than 24!

To deal with that problem, we first define two auxilliary functions am
and pm to parse respectively dates before 20:00 and after 20:00, when
the first digit of the hour is already properly parsed:

let am ib = Scanf.bscanf ib "%1[0-9]:%1[0-5]%1[0-9]";;
let pm ib = Scanf.bscanf ib "%1[0-3]:%1[0-5]%1[0-9]";;

let scan_date_ib ib f =
  Scanf.bscanf ib "%c"
   (function c ->
    let h0 = String.make 1 c in
    match c with
    | '0' | '1' -> am ib (f h0)
    | '2' -> pm ib (f h0)
    | _ -> failwith ("Illegal date char " ^ h0));;

val scan_date_ib :
  Scanf.Scanning.scanbuf ->
  (string -> string -> string -> string -> 'a) -> 'a = <fun>

Remark that we turned to bscanf, that is scanning from scanning
buffers (and not strings), since the scanning is now split into
several phases that should go on scanning from the same data structure
(to do so with strings would involve horrific substring manipulations
of the string argument to pass it to the next step).

As a rule of thumb, scanning from buffers is much more general and
easy than scanning from string or files: phase scanning can be
composed smoothly and scanning from any other data structure is easily
expressed in terms of a basic function scanning from buffers.

For instance, if you insist for scanning from strings, you could define:

let scan_date s = scan_date_ib (Scanf.Scanning.from_string s);;

Now:
# scan_string_date "25:12";;
Exception: Scanf.Scan_failure "scanf: bad input at char number 2: 5".

==============================================================================
6) IMap and ISet
------------------------------------------------------------------------------
** Yamagata Yoriyuki announced:

By the suggestion of Diego Oliver, I implement Map and Set for integers
using Diet.

http://camomile.sf.net/datastruct.html

The interfaces are roughly same to Map and Set in stdlib.  Since they
are used for Unicode, integers are treated as unsigned int.  (So, for
example, ~-1 is treated as the maximal integer.)  If it is not 
desirable, change definitions of infix operators in the beginning of
.ml files.

Comments and suggestion are welcome.

==============================================================================
7) ocamlnet-0.96 released
------------------------------------------------------------------------------
** Gerd Stolpmann announced:

I have recently released the newest versionn of ocamlnet.
This release only addresses issues with the character
set conversion module.

----------------------------------------------------------------------------
What is ocamlnet?
----------------------------------------------------------------------------

A collection of modules for the Objective Caml language which focus on
application-level Internet protocols and conventions.

The current distribution contains:

- a mature implementation of the CGI protocol

- an implementation of the JSERV protocol (AJP-1.2), can be used with
  mod_jserv (Apache JServ) and mod_jk (Jakarta connector) to connect
  application servers written in O'Caml with web servers

- an experimental POP3 client

- a library of string processing functions related to Internet
  protocols (formerly known as "netstring" and distributed separately):
  MIME encoding/decoding, Date/time parsing, Character encoding
  conversion, HTML parsing and printing, URL parsing and printing,
  OO-representation of channels, and a lot more.

Ocamlnet is developed as a SourceForge project:

  http://sourceforge.net/projects/ocamlnet

Developers and code contributions are welcome.

Ocamlnet is licensed under the zlib/libpng license.

----------------------------------------------------------------------------
Where can I download the sources?
----------------------------------------------------------------------------

http://prdownloads.sourceforge.net/ocamlnet/ocamlnet-0.96.tar.gz
http://www.ocaml-programming.de/packages/ocamlnet-0.96.tar.gz

You NEED the PCRE library as prerequisite, and findlib is recommended
(but not required).

----------------------------------------------------------------------------
Where can I read more?
----------------------------------------------------------------------------

http://ocamlnet.sourceforge.net. There is also an online version of the
manual.

----------------------------------------------------------------------
Changes in 0.96:
----------------------------------------------------------------------

Netconversion: A lot of changes, more or less I have rewritten this
module. First, the new module is _much_ faster, you will really
notice it. Second, there are a number of new features:

- There are now cursors. Cursors are pointers into encoded strings
  that can be moved by multiples of characters (not bytes).

- There are a number of string functions that are implemented on
  top of cursors. For example: ustring_length counts the characters
  in a string; ustring_sub extracts a substring.

- The Japanese encoding EUC-JP is fully supported.

- The conversion tables are now loaded at runtime. Optionally, the
  old method of linking them into the executable is still available.

==============================================================================
8) PXP 1.1.94 (development version)
------------------------------------------------------------------------------
** Gerd Stolpmann announced (message edited for correct url):

I have just released a new development version of PXP. This
is a big change:

The Pxp_reader module has been completely rewritten. This fixes some
problems with relative URLs.

Pxp_yacc has been split up into four modules: Pxp_tree_parser contains
now the parser API returning object trees, Pxp_dtd_parser is the parser
API returning DTDs, Pxp_ev_parser is the event-based API, and
Pxp_core_parser is the core of the parser. Pxp_yacc is still available
as compatibility API. As part of the module redesign, Pxp_types includes
now parts of its interface from Pxp_core_types_type. I hope this style
of programming is comprehensible.

I think PXP can now compiled with CVS releases of O'Caml.

It is now possible to turn warnings into errors.

The event-based parser can now preprocess namespaces. Furthermore, there
are normalization filters.   


The new version can be found at the usual place:

http://www.ocaml-programming.de/packages/pxp-1.1.94.tar.gz

** Blair Zajac asked and Gerd Stolpmann answered:

> Has the API changed to Pxp_reader, or will most PXP users will not
> notice this change?

I think most users will not notice the change. I have tried to be as
compatible as possible with previous versions, but there are some corner
cases where the new implementation behaves differently. This is
intentional, as the new implementation tries to fix "conceptual bugs".

The new signature of Pxp_reader is slightly different, but I hope this
does not matter for anybody.

==============================================================================
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 (at least version 6).

: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
(alan.schmitt@inria.fr) and I'll mail it to you, or go take a look at
the archive (http://pauillac.inria.fr/~aschmitt/cwn/). If you also wish
to receive it every week by mail, just tell me so.

==============================================================================

Alan Schmitt