[Haskell-cafe] Missing join and split

Mitar mmitar at gmail.com
Fri Dec 28 17:40:24 EST 2007


On Dec 28, 2007 5:51 PM, Lihn, Steve <horng_twu_lihn at merck.com> wrote:
> Since regex is involved, it is specific to (Byte)String, not a generic
> list.

Oh, this gives me an interesting idea: making regular expressions more generic.

Would not it be interesting and useful (but not really efficient) to
have patterns something like:

foo :: Eq a => a -> ...
foo (_{4}'b') = ...

which would match a list with four elements ending with an element 'b'. Or:

foo (_+';'_+';'_) = ...

which would match a list with embedded two ';' elements. (Last _
matched the remaining of the list.)

OK, maybe guards are not the proper place to implement this as would
add a possibility to make a really messy Haskell programs. But
extending regular expressions to work on any list of elements with
type implementing Eq would be realy powerfull. And then we could use
split in many other than just text processing contexts.

Of course, the problem in both cases is implementing something like
regular expressions efficiently, especially on lists, but this is why
there are smart people around. :-)


More information about the Haskell-Cafe mailing list