[Haskell-cafe] why no replace function in our regular expression libs ?

2013-01-25 Thread Simon Michael
People have put a lot of work into regular expression libraries on
haskell. Yet it seems very few of them provide a replace/substitute
function - just regex-compat and regepr as far as I know. Why is that ?
#haskell says:

sclv iirc its because that's a really mutatey operation in the
underlying c libs
sclv should be simple enough to write a general purpose wrapper layer
that uses captures to create the effect

Secondly, as of today what do y'all do when you need that functionality
?

-Simon

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] why no replace function in our regular expression libs ?

2013-01-25 Thread Clark Gaebel
I've needed this recently, too.

End result: I wrote an Attoparsec.Parser Text, and ran the text through
that.

A regex would have been much nicer...

  - Clark


On Fri, Jan 25, 2013 at 2:06 PM, Simon Michael si...@joyful.com wrote:

 People have put a lot of work into regular expression libraries on
 haskell. Yet it seems very few of them provide a replace/substitute
 function - just regex-compat and regepr as far as I know. Why is that ?
 #haskell says:

 sclv iirc its because that's a really mutatey operation in the
 underlying c libs
 sclv should be simple enough to write a general purpose wrapper layer
 that uses captures to create the effect

 Secondly, as of today what do y'all do when you need that functionality
 ?

 -Simon

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] why no replace function in our regular expression libs ?

2013-01-25 Thread Albert Y. C. Lai

On 13-01-25 02:06 PM, Simon Michael wrote:

People have put a lot of work into regular expression libraries on
haskell. Yet it seems very few of them provide a replace/substitute
function - just regex-compat and regepr as far as I know. Why is that ?

[...]

Secondly, as of today what do y'all do when you need that functionality


I can only speak for myself, why I do not miss regex substitution too much.

Sometimes, regex substitution is exactly the solution, and I use it. But 
the whole job is easily done in a shell script, or even in an editor. So 
I don't use regex substitution in Haskell in this case.


Sometimes, the substitution job is: transform this

  article
  titlecodeMonad/code Tutorial/title
  content.../content
  /article

to this

  !DOCTYPE html etc etc
  html
  headtitleMonad Tutorial/title/head
  body
h1codeMonad/code Tutorial/h1
...
  /body
  /html

In this job, if a regex solution exists, I don't want to know. I just 
use HXT or XSLT.


Sometimes, regex substitution plus Haskell is exactly the solution. Then 
I use regex-compat. It works. One solution is enough. I don't need a 
hundred choices for regex, or a hundred choices for Int.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe