purescript/purescript-strings

Add support for dotAll flag?

chtenb opened this issue · 5 comments

The dotAll flag doesn't seem to be exposed in the Regex module. Could we add it?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/dotAll

Just a question. Is the dotall flag a JS-specific feature? If so, I'm guessing it can't be supported in other backends.

I'm only familiar with the JS backend. Which other backends do I need to check?

garyb commented

I'd never given much thought to regex compat across backends before, it's a pretty tricky issue! Even without considering options the meaning of a regex could differ between backends.

I was almost going to suggest regex should be split into its own js-regex library or something, but then this whole String library is generally very JS centric, given ucs-2, codepoint vs char, etc. 🤔

I wasn't aware those packages were also used when targetting other languages. TIL :)
If we want to transparently expose the native regex implementation of each language there's bound to be differences indeed.
Making a separate string library for each backend makes sense, but that also makes purescript generally less portable.
If we want to abstract over string implementations and string manipulation libraries to create an opaque PureScript string library, then that may be harder to implement for each backend. I'm also not sure if that would have too much impact on string performance.