Previous week Up Next week
Hello,
Here is the latest Caml Weekly News, week 18 to 25 February, 2003.
1) Hashtbl.keys
2) OCaml standard library improvement
3) Timeout
4) Announce: a bdd module
5) graphical notation/representation of functional programs?
6) Announcement: Ocaml-MySQL 0.9.0
7) MozCaml : first release
8) Announcing: CocOCaml (initial release)
======================================================================
1) Hashtbl.keys
----------------------------------------------------------------------
Oliver Bandel asked:
The Hastbl-module is a fine thing. To have functions like
Hastbl.find_all is convenient for a lot of problems, which would
be not so easy to solve, when only hastbl.find would be in
that library.
Well... and Hashtbl.iter seems to work on *all* antries in the
*whole* hash-table, that is: A Hastbl.find_all for each of the
keys in that table.
At least it is, how I understand the decription in the manual.
Well, but Hashtbl.iter is used for unit-functions.
But I need bool-functions, and maybe other tyopes
too.
So, if I want to apply a function with return-type different then
unit, I have to use a second Hash-table to remember, which
keys I have inside my main hastbl (using hashtbl.replace).
Or I may have to use Hastbl.replace instead of Hastbl.add
in my main Hashtbl, where my new data-entry is a list of
the old entry with the new entry appended.
But that all would be easier, if there would be a function
Hashtbl.keys, which give back all keys of a hashtbl.
So, Hashtbl.keys would have the following type:
('a, 'b) t -> key 'a list
Hal Daume answered:
I actually find the OCaml hash table implementation to be very lacking and
have thus written my own, which probably isn't as efficient. Nevertheless
you can find it at http://www.isi.edu/~hdaume/hashtable.ml It requires
garray.ml(i) found at the same location. It doesn't have a keys function,
but such a thing is easy to write:
let get_keys = fold (fun l k _ -> k :: l) []
You could probably do it marginally more efficiently by looking at the
actual implementaiton.
The reason I wrote this not-incredibly hash table implementation is
essentially because I needed a map function for hash tables and there was
no way to implement that on top of the current HashTbl interface. I would
be more than happy to go back to the standard interface if it supported
maps.
Xavier Leroy answered as well:
See Hashtbl.fold, which supports traversing all entries of a hashtable
and build a result of any type. For instance:
> So, Hashtbl.keys would have the following type:
>
> ('a, 'b) t -> key 'a list
let keys h = Hashtbl.fold (fun key data accu -> key :: accu) h []
======================================================================
2) OCaml standard library improvement
----------------------------------------------------------------------
There has been a quite busy discussion about users improving the
standard library. The discussion started with the following message
http://caml.inria.fr/archives/200302/msg00214.html
Stefano Zacchiroli said:
Yes, the ocaml standard library is full (i.e. empty) of a lot of
functions that could be written easily in 1 or 2 lines of ocaml code.
The same functions are the same that you find yourself rewriting in all
the applications you are writing (or linking an "helper" module written
once for all), this is really frustrating and I think make OCaml
standard library less appealing than other languages standard libraries.
I'm collecting from time to time a set of functions that can be easily
added to the standard library to fill this gap. Probably a lot of other
OCaml programmers are doing the same. Is there any chance to see this
functions in the standard library?
Better stated: if we, ocaml programmer, collect a set of functions that
are widely felt to be missing, could the OCaml team review the
corresponding implementation and add them to the ocaml standard library
in the next ocaml release?
Here are some excerpts of the answers:
Sven Luther said and Amit Dubey answered:
> But the discusion could now be ported to a separate mailing list on the
> new sourceforge project, could it not ? The licence flamewar also i
> guess.
>
Good idea, Sven!
I've created a mailing list, and you can sign up at:
http://lists.sourceforge.net/lists/listinfo/ocaml-lib-devel
The project page is it:
http://sourceforge.net/projects/ocaml-lib/
John Max Skaller asked and Xavier Leroy answered:
> One worthy subgoal would be to *eliminate* the other licences:
> I believe the Str module is archaic and has 'other licence'
> and we might try to eliminate it -- the Ocaml team itself is
> working on that isn't it?
Right. In the working sources, Str was reimplemented from scratch,
and the new implementation is entirely under the same license as all
other libraries (LGPL minus clause 6).
Stefano Zacchiroli said:
As the source of this post-fest let me restate what was my original
idea that definitely collide with sourceforge project and similar ...
My idea was not to start a new ocaml library project full of a lot of
really useful functions but split away from the ocaml team ocaml
distribution. We already have many of them and no one of them managed to
succeed in be widespreaded enough (CDK is surely the best example!).
What I proposed was to collect a set of additions to the ocaml
_standard_ library so that ocaml implementors can take suggestions
and/or code from the ocaml programmers. This code was supposed to
_be_part_of_the_ocaml_standard_library_, not a fork.
In order to be part of the ocaml standard library functions should be:
- a few and not tons
- with interfaces and names similar to functions that already exist in
the standard library
- addons and not implementation of new impressive data structures, they
don't need to be part of a standard library
- recyclable as single units and not only as a whole library so that
memebers of the ocaml team could pick single functions
- with a license compatible with ocaml sources, the beter obviously is
the same license of the rest of ocaml sources
Anyone can be useful following this idea submitting small whishlist bug
reports including implementations of functions for the stdlib, but
creating a group which agree on a set of common functions is probably
better.
If someone is interested in working on such an approach please mail me
privately so that we can share ideas and code to propose to the ocaml
team.
Benjamin Pierce proposed: Alternative proposal: COAN
(this different thread has many replies and starts at
http://caml.inria.fr/archives/200302/msg00291.html)
Although I share the impulse behind the recent discussions about
improving the standard library, I wonder if it is actually missing the
main point: there are *already* lots of improvements on the standard
library out there -- the Unison project has one; probably there are at
least a dozen better ones out there -- but nobody can find them! This
leads to an idea for a different way of soaking up people's hacking
energies... :-)
The single thing that I think would make the biggest difference for the
OCaml community is a central repository for OCaml source code --
something analogous to the CPAN archive for PERL modules. I'm aware of
all the thorny problems involved in really doing something like this
"right" for OCaml, but frankly I'd rather have something simple and
useful, now, than the right thing, someday. The CDK was an impressive
attempt to do the right thing, but it was too ambitious and sank under
its own weight.
The minimal functionality that seems needed is something like this:
- a single repository (on somebody's web server, or maybe SourceForge)
where stuff lives
- an easy way for authors to upload stuff to the repository (and to
re-upload new versions of their stuff)
- an easy way for users to browse and download stuff
- some way (at least informal) to indicate dependencies between one
thing and another in the repository
Of course, much more functionality could be imagined and wished for
(e.g., a machine-readable representation of dependencies, provisions for
mutiple versions, standard installation procedures, documentation
standards, etc., etc.), but all that can be added later, in light of
experience. For now, let's let a thousand flowers bloom... and just
encourage them to bloom in the same garden!
======================================================================
3) Timeout
----------------------------------------------------------------------
Salvatore Altavilla asked:
I would want to introduce a Timeout for input operations (a
floating-point value representing a time in seconds) of 15 second.
Wolfgang Beck answered:
use 'select':
let rd_ready, wr_ready, exc_ready = select [sock] [][] 15.0
in
match rd_ready with
h :: _ ->
Unix.recvfrom h !buf 0 max []
| [] -> (* handle timeout *)
'select' on Windows is restricted to sockets, on Unix you can
use any file_descr.
======================================================================
4) Announce: a bdd module
----------------------------------------------------------------------
Scott announced:
I'd like to announce a binary-decision diagram module. Binary
Decision Diagrams present a method for evaluating large boolean
expressions efficiently, and are often used in model checking.
This module is new and could use some feedback and/or bug reports.
The source code and documentation is freely available here:
http://chronis.pobox.com/~scott/code/
======================================================================
5) graphical notation/representation of functional programs?
----------------------------------------------------------------------
Oliver Bandel asked and Jocelyn Sérot answered:
>When using graphical representations like in
>"The Craft of Functional Programming", so that
>a function is a box with in- and output, then
>it's a convenient way of looking at functional
>programs.
>
>Is that technique of overview more elaborated
>used by other people?
>
>Shouldn't it possible to have a graphical notation
>for FP, like a functional aequivalent of the notation,
>that is used in the OO-programmers world, where
>classes and methods and attributes and so on
>are presentated in a graphical manner?
>
>Are there papers on that topic?
>Or is functional programming in higher spheres
>done comepletely an algebraic form (lambda calculus)?
Here are two papers i am aware of (sorry, i don't have the urls at hand
now, but a search on the web should give them to you) :
* John Reekie. "Visual Haskell : a first attempt", TR 94.5, U.
Sydney,, 1994.
* Joel Kelso. "A Visual representation for functional programs", TR
CS95-01, CS Dept, Murdoch Univ, 1995.
You can also have a look at Reekie's subsequent work on dataflow signal
procesing (including his phd thesis)
@phdthesis{ reekie95realtime,
author = "H. J. Reekie",
title = "{Realtime Signal Processing: Dataflow, Visual and
Functional Programming}",
address = "University of Technology at Sydney, Australia",
year = "1995",
url = "citeseer.nj.nec.com/article/reekie95realtime.html" }
or on the work
* of Launchburry on Hawk (http://www.cse.ogi.edu/PacSoft/projects/Hawk)
* at Chalmers on Lava (http://www.math.chalmers.se/~koen/Lava),
* O'Donnell on Hydra (http://www.dcs.gla.ac.uk/~jtod/Hydra/)
The laters all use FP to describe hardware systems.
Finally, you could also have a look at
* Camlflow
(http://wwwlasmea.univ-bpclermont.fr/Personnel/Jocelyn.Serot/camlflow.html)
a system I developed to describe data-flow graphs as caml programs.
======================================================================
6) Announcement: Ocaml-MySQL 0.9.0
----------------------------------------------------------------------
Shawn Wagner announced:
Bindings for accessing MySQL databases from ocaml.
Last version was 0.1.something, but, hey, it's been a long time. This code
is pretty stable. Barring any bug reports with this new release, it'll be
1.0 soon.
Get it at http://raevnos.pennmush.org/code/ocaml-mysql-0.9.0.tar.gz
From the change log:
* Big version bump, as this has been stable for years. 1.0.0 soon.
* Dynamic linking works at long last.
* Link with -lz as newer versions of mysql than what I was using need it.
Reported by several people.
* Updated my testing copy of mysql to 3.23.55.
* New html documentation in the doc directory. Generated by ocamldoc instead
of ocamlweb.
* New quick_connect, quick_change and defaults convienence functions.
I'm going to start on a non-backwards-compatible version targetting MySQL
4.X instead of 3.X that's organized a bit more nicely and with more
higher-level stuff instead of just exporting the C functions. I'd also like
to support any database-independant schemes like have been mentioned
recently on the list that people bring out.
======================================================================
7) MozCaml : first release
----------------------------------------------------------------------
Maxence Guesdon announced:
We are happy to announce the first release of MozCaml, a SideBar Tab
for Mozilla dedicated to the Caml language. (A SideBar is some kind of
plugin which appears on the left of Mozilla's window, the same way as the list
of bookmarks or the history.)
It provides direct access to many information about Objective Caml:
news, user's manual, library reference and the humps (the collection
of links to Caml-related stuff). Each of these sources can be browsed
throughout several views, including contents tree, indexes or search
engines.
For more information, screenshots and installation instructions, see:
http://caml.inria.fr/mozcaml/
Comments and suggestions are welcome.
======================================================================
8) Announcing: CocOCaml (initial release)
----------------------------------------------------------------------
William Neumann announced:
I am pleased to announce the initial release of CocOCaml, a Mac OS X
wrapper for the OCaml toplevel.
Inspired by the Toplevel wrapper that comes with the Windows distribution
of OCaml, as well as Steve Harris's Cocoa Top Level application[1],
CocOCaml addresses most of the problems one encounters while running
the Toplevel in a Mac OS X Terminal window. It does this by providing
the user with an area to easily edit any commands prior to sending them to
the interpreter and a command history area that stores all of the commands
previously sent to the interpreter. The command history area makes it
easy to step through the prior commands and copy them into the command
entry area for additional editing before sending it back to the
interpreter.
For screen shots, additional information, or downloading the application,
head on over to:
http://www.cs.unm.edu/~wneumann/cococaml
If you have any questions that can't be answered by the materials at the
web site, feel free to e-mail me.
Requirements:
Mac OS X 10.2 (might work on earlier releases, but has not been tested)
A previously installed OCaml distribution
Knowledge of the path to your OCaml Toplevel executable
Thank you,
William D. Neumann
[1] CocOCaml was originally intended to be a fix for some of the problems
I was having with Cocoa Top Level, such as not being able to send a
command to the interpreter properly if the cursor was not at the end of
the current command. However, about two hours into looking through Mr.
Harris's source code and trying to patch it, I decided this would be a
good opportunity to learn a bit more about Cocoa programming by writing my
own app, hence the creation of yet another application. If you would like
to see/use Cocoa Top Level, it is available at:
http://home.att.net/~scharris/OSX/
======================================================================
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