[Haskell-beginners] wrapping text in a multiline string

Chaddaï Fouché chaddai.fouche at gmail.com
Wed Jun 6 19:50:44 CEST 2012

On Wed, Jun 6, 2012 at 10:39 AM, Rico Moorman <rico.moorman at gmail.com> wrote:
> Now I am wondering how I would integrate this in the replacement
> function or how to rewrite it properly.
> Looking at the type signature of =~~ (with my limited knowledge) it
> seems that I would have to "use" RegexMaker adding up the CompOptions
> needed?
> (=~~) :: (RegexMaker Regex CompOption ExecOption source, RegexContext
> Regex source1 target, Monad m) => source1 -> source -> m target

What's non-obvious and trip a lot of people when they try to use
regexes in Haskell is that most regex libraries use the same
interface, which is specified in the regex-base and consists of
several typeclasses that offers a very high degree of flexibility.
=~and =~~ are only the simplified front-ends to this and are pretty
inadequate for advanced usages (for instance compile and use multiple
time the same regex, you should really avoid =~ in this case, or
additional regex compilation options). To see the basic interface,
look at Text.Regex.Base.RegexLike :
In particular, what you want to do should be done with makeRegexOpts
and match (or matchM), note that the available compilation and
execution options can vary depending on the regex library you use and
for regex-pcre, they're documented there :


More information about the Beginners mailing list