caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: jtbryant@valdosta.edu
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Stdlib
Date: Tue, 01 Nov 2005 04:20:15 +1100	[thread overview]
Message-ID: <1130779215.11424.21.camel@rosella> (raw)
In-Reply-To: <1130769705.488.16.camel@starlight>

On Mon, 2005-10-31 at 09:41 -0500, Jonathan Bryant wrote:
> Quick (and rather random question) about the standard library.  I
> noticed that, like the STL, many of the modules are very similar and
> implement many of the same functions (iter, map, etc.).  Unlike the STL
> or the Java Standard API, these modules are each completely
> independent.  Why hasn't there been a push to do something like
> functorize these modules? 

Because the technology to do that is WAY in advance of the
current Ocaml.

What you are asking for is *polyadic* functions, aka
functorial polymorphism. For example, a fold function
that works on all data structures, that is, polymorphic
not just on the data type (such as int), 
but also the data functor (such as list).

Such a function would never work with abstracted modules,
it would require data types to be defined entirely algebraically.

All of this can be done (I worked on a system that did it),
however it is definitely non-trivial. It is well in advance
of anything Haskell can do also.

In fact, C++ DOES provide such functions: the STL is built
on this concept. .. however the mechanism is not 'type safe': 
it works only by hackery based on overloading
and dependent name lookup.

This problem is partly solved in Extlib, which provides an
equivalent concept to STL iterators. However the Extlib
solution, whilst not so general as STL, is fully safe
(since it is written in Ocaml .. :)


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  reply	other threads:[~2005-10-31 17:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-31 14:41 Stdlib Jonathan Bryant
2005-10-31 17:20 ` skaller [this message]
2005-11-01  0:11   ` [Caml-list] Stdlib Jonathan Roewen
2005-11-01  8:17     ` skaller
2005-11-01 16:02 ` Brian Hurt
2005-11-01  0:07 Stdlib Jonathan Bryant
2005-11-01  6:08 ` [Caml-list] Stdlib Jacques Garrigue
2005-11-01 13:54 ` Jon Harrop

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1130779215.11424.21.camel@rosella \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@yquem.inria.fr \
    --cc=jtbryant@valdosta.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).