duncan.coutts: > On Wed, 2006-07-05 at 05:58 -0500, John Goerzen wrote: > > Hi, > > > > In MissingH, I have a bunch of little functions that operate on lists. > > Some, like uniq (which eliminates duplicate elements in a list), operate > > on (Eq a => [a]) lists. Others, like strip (which eliminates whitespace > > at the start and end), operate on Strings only. > > > > Most functions of both types would be useful on ByteStrings and lazy > > ByteStrings. Most of these functions are written in terms of Data.List > > functions or list primitives that have equivolents in Data.ByteString. > > > > So, my question is: is there a clever hack available to me so that I > > could have 1 version of each function, and have it work on all three > > different types of input? I'd rather avoid having 3 versions, that are > > exactly the same except for imports. > > People sometimes talk about doing a type class to cover string like > modules. > > What functions are you thinking of btw? We may want to include them in > the ByteString modules anyway (possibly directly rather than in terms of > other functions, to take advantage of tricks with the representation).
Spencer Janssen is actually working on such a class (String) to deal with this, initially to support [a] and Word8 and Unicode bytestrings, as part of his Summer of Code project. Note also that we have the Foldable and Monoid classes, which support parts of a String interface. -- Don _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
