RFC: general sequences

John Meacham john at repetae.net
Mon May 23 16:29:34 EDT 2005

On Mon, May 23, 2005 at 10:22:38PM +0200, Benjamin Franksen wrote:
> On Monday 23 May 2005 18:41, Bulat Ziganshin wrote:
> > RP> On Mon, May 23, 2005 at 01:38:59PM +0200, Henning Thielemann 
> wrote:
> > >>  It would be great if we had a class for finite sequences with
> > >> instances Data.List, Data.Array, Data.Sequence. Maybe the new
> > >> identifiers (<|), (|>) and so on should be names of methods of a
> > >> such a class instead of separate functions.
> >
> > RP> What would that buy us?  I can't think of many useful functions
> > that RP> would use that interface, what with (<|) lazy for lists and
> > strict for the other two, and (|>>) cheap for sequences and expensive
> > for the other two.
> >
> > at least, it will be great to have analogues of length, map, filter,
> > partition and a number of other operations defined in classes and
> > supported for variety of data structures. i think it's omission in
> > H98 standard that this names belongs only to lists and not defined in
> > some classes like (+) and (>)
> A agree completely. Almost all of the functions in Data.Seq have the 
> same name and type signature (modulo the data type) and provide the 
> same functionality as the corresponding ones for lists (in the 
> Prelude). A type class Sequence to capture these common features would 
> be great. It would also mean we can import module Sequence unqualified. 
> A problem is that the names conflict with the ones from the Prelude, so 
> that this style can only be used when hiding all the list stuff from 
> Prelude.

I would much prefer if all of the data structures had their own
interface in addition to being instances of a common class. so we could

import Data.GenSeq -- get the general interface
import Data.Sequence(Seq) -- all we need is the type name (and the implicitly imported instance)

This would nicely decouple the development of the general class from
particular data structures, since they can stand on their own if needed.

John Meacham - ⑆repetae.net⑆john⑈ 

More information about the Libraries mailing list