From: Goswin von Brederlow <goswin-v-b@web.de>
To: Alp Mestan <alp@mestan.fr>
Cc: David Rajchenbach-Teller <David.Teller@ens-lyon.org>,
caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Strings
Date: Sat, 04 Apr 2009 23:51:50 +0200 [thread overview]
Message-ID: <87ocvc6qa1.fsf@frosties.localdomain> (raw)
In-Reply-To: <cbe39dfc0904040226k5516a9bcvd57aa3c7b8fe5528@mail.gmail.com> (Alp Mestan's message of "Sat, 4 Apr 2009 11:26:46 +0200")
Alp Mestan <alp@mestan.fr> writes:
> I think providing both capabilities is the best solution.
Phantom types solvethis beautifully with not truntime penalty.
GO BATTERIES!
> However, let's study Haskell's strings.
> They simply are a list of characters. This let the ability to use heavily
> list-related functions (take, takeWhile, drop, dropWhile, map, etc.). On the
The beauty of ocaml strings is that they are really compact. An ocaml
string on 32bit is 5-8 bytes longer than the contained string and 9-16
bytes on 64bit.
On the other hand a list of characters is 8/16 times as large. Not to
mention that you have no random access.
> other hand, OCaml's standard library lacks of many functions for strings ! I
> think this is too much imperative oriented. Maybe we could try to implement
> (for Batteries or in a separate project) string lists and then use the power
> of Batteries' list module with many (really many... that's a real pleasure to
> read its documentation) functions to work with. I think with a bit of internal
> laziness, we could get a great immutable string type with many functions to
> manipulate it.
> But I guess there are many cons to do so, otherwise it would have been
> "standardized".
Mutable/Immutable can really nicely done with phantom types and is
independent of the data structure used. It works for strings, lists,
arrays, sets, trees, ... and I think all standard modules should have
it. The official standard lib is rather lacking there but that is why
there is Batteries. The more I hear/see of it the more I like it.
As for char lists for strings you can always convert strings to char
lists when that is a better representation. I've done so myself on a
number of ocasions. But just as often I used strings as char
arrays. Doing e.g. String.blit with char lists would be ugly.
MfG
Goswin
next prev parent reply other threads:[~2009-04-04 21:51 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-03 11:56 Strings Jon Harrop
2009-04-03 12:25 ` [Caml-list] Strings Paolo Donadeo
2009-04-03 14:18 ` Ashish Agarwal
2009-04-03 14:46 ` Jon Harrop
2009-04-03 15:03 ` Daniel Bünzli
2009-04-03 16:52 ` Martin Jambon
2009-04-03 17:50 ` Daniel Bünzli
2009-04-03 19:46 ` Paolo Donadeo
2009-04-03 20:41 ` Harrison, John R
2009-04-04 10:11 ` Jon Harrop
2009-04-04 11:12 ` David Teller
2009-04-04 11:40 ` Jon Harrop
2009-04-04 12:34 ` David Rajchenbach-Teller
2009-04-18 12:31 ` Arkady Andrukonis
2009-04-04 10:13 ` Jon Harrop
2009-04-03 21:44 ` Goswin von Brederlow
2009-04-04 9:10 ` David Rajchenbach-Teller
2009-04-05 10:06 ` Strings Zheng Li
2009-04-06 9:20 ` Strings David Rajchenbach-Teller
2009-04-06 10:07 ` Strings Goswin von Brederlow
2009-04-06 11:03 ` Strings Zheng Li
2009-04-04 17:11 ` [Caml-list] Strings Kuba Ober
2009-04-04 17:26 ` Jon Harrop
2009-04-05 20:54 ` Richard Jones
2009-04-05 23:40 ` Daniel Bünzli
2009-04-03 18:24 ` Florian Hars
2009-04-03 20:34 ` Arnaud Spiwack
2009-04-04 10:20 ` Jon Harrop
2009-04-04 9:14 ` David Rajchenbach-Teller
2009-04-04 9:26 ` Alp Mestan
2009-04-04 10:55 ` blue storm
2009-04-04 21:51 ` Goswin von Brederlow [this message]
2009-04-04 23:35 ` Yaron Minsky
2009-04-05 9:36 ` David Rajchenbach-Teller
2009-04-05 10:08 ` Alp Mestan
2009-04-05 21:41 ` Goswin von Brederlow
2009-04-05 21:40 ` Goswin von Brederlow
2009-04-05 2:55 ` Jon Harrop
2009-04-05 4:22 ` Edgar Friendly
2009-04-05 7:03 ` Goswin von Brederlow
2009-04-05 6:57 ` Goswin von Brederlow
2009-04-05 7:11 ` Jon Harrop
2009-04-04 10:11 ` Jon Harrop
2009-04-04 21:39 ` Goswin von Brederlow
2009-04-05 7:14 ` Romain Beauxis
2009-04-05 9:34 ` David Rajchenbach-Teller
2009-04-05 21:37 ` Goswin von Brederlow
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=87ocvc6qa1.fsf@frosties.localdomain \
--to=goswin-v-b@web.de \
--cc=David.Teller@ens-lyon.org \
--cc=alp@mestan.fr \
--cc=caml-list@yquem.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