GHC's PackedString library goes some way towards providing
all this. However, a PackedString currently just records the
length of the sequence of bytes it points to, but could without
much incident record the byte offset to start at as well.

hth
--sigbjorn

Keith Wansbrough <[EMAIL PROTECTED]> writes: 
> 
> In a thread "The Imperative strikes back?" on comp.lang.functional a
> couple of weeks ago, Brian Rogoff <[EMAIL PROTECTED]> mentioned:
> 
> > [..]  I really wish that
> > the basic string handling capabilities in some FP languages 
> > were a bit better thought out. For example, I think in Haskell
> > strings are listt of characters. Any Haskell folk care to provide
> > a rationale for that decision? If I were going to restrict myself
> > to one kind of built-in string type, I'd have made it an array of
> > characters, or better, gone with subsequence references. Why? My
> > experience is that strings behave at least like bidirectional
> > conatiners, really like random access containers.  Subsequence
> > references capture that behavior.
> 
> Other posters on the list mentioned the Standard ML Basis Library's
> SUBSTRING signature (see
> http://cm.bell-labs.com/cm/cs/what/smlnj/doc/basis/pages/substring.html)
> ..
> This provides operations on a datatype "Substring" consisting of an
> underlying string, a start index, and a length.  The idea is that the
> usual substring operations of span, take, drop, etc., can be performed
> without expensive copying.  Operations to convert between String and
> Substring are provided, but these need only be performed when string
> processing is complete; a more efficient internal representation (say
> GHC's immutable byte array plus two Int#s) can be used during
> processing.
> 
> Does anyone else think this is a brilliant idea that should be
> implemented?  I float the idea in case (1) someone else is already
> doing this, or (2) someone else is interested in doing it.  It
> shouldn't be too hard, but I don't have time right now...
> 
> --KW 8-)
> 
> 
> 
> 
> -- 
> : Keith Wansbrough, MSc, BSc(Hons) (Auckland) 
> ------------------------:
> : PhD Student, Computer Laboratory, University of Cambridge, 
> England. :
> :  (and recently of the University of Glasgow, Scotland. [><] 
> )       :
> : Native of Antipodean Auckland, New Zealand: 174d47' E, 
> 36d55' S.    :
> : http://www.cl.cam.ac.uk/users/kw217/  
> mailto:[EMAIL PROTECTED]     :
> 
> :-------------------------------------------------------------
> --------:
> 
> 


Reply via email to