[Haskell-cafe] Clever generic ByteString hack?

John Goerzen jgoerzen at complete.org
Wed Jul 5 06:58:52 EDT 2006


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.

Thanks,

-- John


More information about the Haskell-Cafe mailing list