[MLton] MLton library project
Vesa Karvonen
vesa.karvonen at cs.helsinki.fi
Mon Sep 25 23:23:03 PDT 2006
Hi All,
As I've expressed earlier, I'd love to see a ton of libraries being
distributed with MLton. What I personally like about SML is that it is a
relatively simple language (arguably much simpler than OCaml and Haskell,
for example), but still expressive enough for one to build powerful
abstractions. With MLton's low abstraction penalty one can both express
the abstractions and actually use them in production code. What SML
lacks, however, is libraries. A simple language like SML (or Scheme)
needs a comprehensive set of utility libraries to make programming really
convenient. While the SML Basis library provides a relatively complex IO
stack, some support for systems programming, basic support for primitive
numeric types, and support for a few primitive sequence types, it provides
very few utilities for programming convenience.
As I currently have the opportunity to do some SML hacking at both home
and work (SSH), I'd like to actually do something about it and start a
collaborative project to build libraries for SML and MLton by polishing up
and contributing some libraries. Below is a brief list of some basic
utility libraries that we'd like to contribute in the short term. Most of
these are already in a usable form while some are at the prototype stage.
- An extended Basis library with some minor extensions to the library
signatures and structures. These are done in a non-intrusive manner by
simply rebinding the signatures and structures. The reason for extending
the Basis library is that the extensions naturally belong to specific
Basis library modules. The extensions include things like isomorphisms
and embeddings (pairs of the form (toX, fromX)), bounds (pairs of the
form (minX, maxX)), and some other routines.
- Basic: a module with several basic combinators (like id, const, fst,
snd, repeat, sectioning, application and piping operators, and more)
that are also made available at the top-level.
- Fix: a module implementing a generic fixpoint framework allowing one to
compute fixpoints over arbitrary products. This ~20 line library
basically solves the "fix, fix2, fix3, ..." problem.
- Fold: a framework (see mlton.org/Fold) to support defining variable arity
functions. This is used by a number of the utilities.
- Format: a combination of printf + scanf.
- Iter: combinators for writing imperative for-loops.
- Parsec: a port of Daan Leijen's Parsec library.
- Prettier: a port of Philip Wadler's Prettier Printer and some of Daan
Leijen's PPrint (eventually all of it).
- Product and Sum types.
- Promise: a translation of André van Tonder's SRFI-45 to SML.
- SeqProduct: combinators for manipulating arbitrary products (not just
pairs) of sequences (arrays, lists, ...).
- Type: a framework for structural and nominal type-indexed functions of
single type parameter. Also, implementations of type-indexed values
such as
- Arbitrary (generate random values of arbitrary SML types; inspired
by the QuickCheck library by Koen Claessen and John Hughes),
- Compare (generic compare: 'a * 'a -> order),
- Eq (generic equality: 'a * 'a -> bool, 'a not necessarily equality),
- Hash (hash arbitrary SML values),
- Pickle (pickle/unpickle arbitrary SML values),
- Read (read arbitrary SML values in SML syntax), and
- Show (pretty print arbitrary SML values to SML syntax; uses Prettier).
- UnitTest: a simple unit testing framework with support for both ad hoc
tests as well as QuickCheck style randomized testing of specifications.
- With: basic combinators for scoped resource management (IOW, "with"
-functions).
(Of course, these are not the only libraries that I'd like to see!)
As I said, I'd like to see more libraries distributed *with* MLton. One
reason for this is that any extra step required to install libraries after
installing the compiler is going to cut off a large number of potential
users. Having readily accessible libraries is an effective way to attract
new users to a language (or compiler or both). As a case in point, the
Computer Language Shootout project (http://shootout.alioth.debian.org/)
generally allows using libraries that come with the compiler, but is
reluctant to install additional libraries. Many of the SML benchmark
implementations could be simplified (both reduced in length and made more
readable) using just very basic utilities such as repeat, for, push, and
pop. Also, some of the benchmarks could benefit from some more specific
libraries such as a regex library. Having simpler (and just as fast)
implementations of the SML benchmarks certainly wouldn't drive potential
users away from SML.
As for organization, to make a collaborative library project possible, we
would need a shared (SVN) repository or a module (or a subdirectory) within a
repository with commit access to library maintainers (contributors) and a
mailing list (not necessarily immediately). I was hoping that mlton.org (i.e.
Stephen Weeks) would be able to provide those with a small effort. As the
library project would gain more contributors (I hope!) we would probably need
to define some minimal processes (e.g. peer review, voting to accept / reject
/ remove libraries) to maintain and further improve quality. I would like
to keep the library project open to experimental developments meaning that
not everything needs to be completely polished before it ends up in a
repository. However, more experimental stuff should probably be separated
to a designated "sandbox" before being integrated with the more stable
components.
-Vesa Karvonen
More information about the MLton
mailing list