[MLton-user] Extended Basis Library: proposed sequence concept

Stephen Weeks sweeks at sweeks.com
Wed Mar 21 17:21:33 PST 2007


>       I was starting on a »generic« zip/unzip library for
> sequences,but realized that there was not any actual common
> ancestry for the signatures in the sequence directory.  I put
> this together by distilling the commonality between lists,
> arrays, and vectors.

You might like to have a look at:

  http://mlton.org/cgi-bin/viewsvn.cgi/mltonlib/trunk/com/sweeks/basic/unstable/

In particular, the README has a description of the signature hierarchy
that I used for sequences.  I've included the relevant section of the
README below.  The code doesn't yet use the (very nice) naming
convention for concept signatures, but you might find some useful
ideas.

----------------------------------------------------------------------

This library uses signature inclusion to provide a consistent
interface to all sequence types.  The inclusion hierarchy (subtyping)
looks like this:

     ENUMERABLE
         |
         |
         |
     SLICEABLE
        / \
       /   \
      /     \
  SEQUENCE  SLICE

The ENUMERABLE signature is for any container whose elements can be
enumerated.  The SLICEABLE signature is for any sequence of which one
can take contiguous subsequences.  The SEQUENCE signature is for
arbitray sequences, of which one can build arbitrary subsequences.
The SLICE signature is for slices of some base sequence.

The following structures match the SEQUENCE signature:

  Array, List, Seq, String, Vector

The following structures match the SLICE signature:

  ArraySlice, Substring, VectorSlice

The Seq structure has no counterpart in the basis library.  It is for
arbitrary sequences, including lazy and infinite ones.  All other
sequence types can be converted to and from Seq.t.



More information about the MLton-user mailing list