Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: brogoff <brogoff@speakeasy.net>
To: Ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] unix.chop_extension
Date: Thu, 27 May 2004 10:29:03 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.58.0405271005270.10396@shell2.speakeasy.net> (raw)
In-Reply-To: <20040526164308.GA22145@redhat.com>

On Wed, 26 May 2004, Richard Jones wrote:
> On Wed, May 26, 2004 at 01:21:01PM +0200, Alex Baretta wrote:
> > Actually, I'm a happy user of Str, but I find the absence in Ocaml of a
> > functional "canonical" regexp feature striking.
>
> I'm fascinated to know what this "functional" API would look like.  I
> use Pcre and it doesn't appear to have any global internal state
> AFAICS ...

As you note, the interface to Pcre, unlike Str, appears stateless.

If you examine some functional data structure libraries, like Martin Erwig's
FGL, or Gerard Huet's ZEN, you notice that they use the idea of "location +
context" (similar to the C++ STL, where the locations are iterators)  to
navigate the structure. For string processing, the context is the entire string,
and the location is the pair of endpoints of the current string. So it seems
that the right way to a functional API for string processing would be in terms
of substrings, { base : string; left : int; right : int } or just
string * int * int, which is what is done in the SML Basis. The idea extends
naturally to regexp scanning, and it's easy to see how to modify the Str
interface to use substrings, eliminating Not_found exceptions by considering
an empty substring to be a failed match.

Of course, substrings make sense when the underlying string is array like, not
in FPLs like Haskell which use lists of chars as strings, but I consider that an
egregious error of Haskell.

-- Brian

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  parent reply	other threads:[~2004-05-27 17:29 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-24 20:04 skaller
2004-05-24 22:01 ` skaller
2004-05-25  8:46 ` Alex Baretta
2004-05-25  9:35   ` skaller
2004-05-25  9:46     ` Alain Frisch
2004-05-25 10:47       ` skaller
2004-05-25 11:51         ` sejourne kevin
2004-05-26 11:18           ` Florian Hars
2004-05-25 14:06         ` [Caml-list] Re: AAP (was: unix.chop_extension) Christophe TROESTLER
2004-05-25 13:37     ` [Caml-list] unix.chop_extension John Goerzen
2004-05-25 19:17     ` Richard Jones
2004-05-27  8:15   ` YANG Shouxun
2004-05-27  9:47     ` skaller
2004-05-26  9:05 ` Xavier Leroy
2004-05-26  9:35   ` Luca Pascali
2004-05-26  9:56   ` Remi Vanicat
2004-05-26 10:34   ` skaller
2004-05-26 13:27     ` Damien Doligez
2004-05-26 15:50       ` skaller
2004-05-26 16:04         ` Damien Doligez
2004-05-27  4:33           ` skaller
2004-05-27  4:56             ` John Goerzen
2004-05-28 16:44             ` Damien Doligez
2004-05-28 19:34               ` skaller
2004-05-29  8:37                 ` Damien Doligez
2004-05-29 10:01                   ` skaller
2004-05-29 16:02                     ` David Brown
2004-05-26 11:21   ` Alex Baretta
2004-05-26 16:43     ` Richard Jones
2004-05-27  4:48       ` skaller
2004-05-27  7:46         ` Markus Mottl
2004-05-27  9:33           ` skaller
2004-05-27 17:29       ` brogoff [this message]
2004-05-28 12:00         ` Keith Wansbrough
2004-05-28 16:43           ` brogoff
2004-05-28 17:49             ` Marcin 'Qrczak' Kowalczyk
2004-05-28 11:23       ` Alex Baretta

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=Pine.LNX.4.58.0405271005270.10396@shell2.speakeasy.net \
    --to=brogoff@speakeasy.net \
    --cc=caml-list@inria.fr \
    /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