My impulse is to say yes, especially if I'm using the same regex in multiple code locations, but this article indicates that the library will cache the compilation for me (which I'm not even sure how it would do):
There’s normally no need to compile regular expression patterns. A pattern will be compiled the first time it’s used, and your Haskell runtime should memoise the compiled representation for you.
If you reuse a regular expression then it is worthwhile to use the RegexMaker type class to define the "compiled" regular expression. It has the ability to take additional options and the ability to report compilation failure in your choice of Monad.
To use the "compiled" form you can use 'match' or 'matchM' from RegexLike which gives you the equivalent to =~ or ==~ operators.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With