Why are strings linked lists?
David Roundy
droundy at abridgegame.org
Sat Nov 29 07:10:57 EST 2003
On Fri, Nov 28, 2003 at 04:56:02PM -0500, Mark Carroll wrote:
> (shifting to Haskell-Cafe)
>
> On Fri, 28 Nov 2003, Donald Bruce Stewart wrote:
>
> > ajb:
> (snip)
> > > As a matter of pure speculation, how big an impact would it have if, in
> > > the next "version" of Haskell, Strings were represented as opaque types
> > > with appropriate functions to convert to and from [Char]? Would there be
> > > rioting in the streets?
>
> I'd be sad to lose some convenient list-based string type because I make a
> lot of use of the fact that strings are lists in processing them.
I agree. What I think might be a nice compromise at some point would be to
have a "String" class, which would support conversion to either String or
to PackedString, or to CString. Then library functions wanting a String
parameter could accept a parameter of any instance of the String type.
Functions returning a string could do so using whatever is the most
efficient/convenient instance of class String. Perhaps that would be
overkill, but it would be nice to be able to do (for example) a
getCurrentDirectory and corresponding setCurrentDirectory without ever
converting the directory name from a CString to a String (presuming the
standard system calls used by getCurrentDirectory etc accept CStrings).
--
David Roundy
http://www.abridgegame.org
More information about the Haskell-Cafe
mailing list