Added some shortcuts for commonly used flags#67
Conversation
|
What about making flags into a |
88e16f7 to
04a5cf7
Compare
|
Added the changes 😄 |
|
The Also, and this is just a style thing, but please don't whitespace-align things in columns. 😄 While it's true these things are unlikely to change, since it's a JS interface, we prefer not to do that as they make for worse diffs if something comes along that needs the "column" to be wider. We don't have an officially adopted style guide, but there's this: https://github.com/ianbollinger/purescript-style-guide/ which is being worked on by consensus, and has a section about not aligning code. |
|
Is something like |
|
Why not use the full names, like |
|
My reasoning was that it's less likely to clash with existing names in a module and the names are shorter. It's an interface to the JS RegExp object, so devs already know the flags as g, i, u, ... rather than global, ignoreCase, etc. That's why I went with single letters. And in the situation where you use a few of them, you can fit that in one line nicely: |
|
|
I'm not too worried about this. Names will tend to overlap but we can import qualified, and we should try to improve on JS where possible - I certainly find myself having to look up the meanings of the various one-letter flags regularly. |
|
That's true, you end up having to look up them up. Ok, I'll update |
| } | ||
|
|
||
| -- | Flags that control matching. | ||
| data RegexFlags = RegexFlags RegexFlagsRec |
There was a problem hiding this comment.
Please use newtype and derive Newtype RegexFlags _ here.
There was a problem hiding this comment.
Oh, never mind the Newtype instance. It won't work because of the row there. Ugh, we need ~ types.
There was a problem hiding this comment.
It won't? I can see that it wouldn't work as long as the RegexFlagsRec synonym is used rather than the type, but what's the problem here?
There was a problem hiding this comment.
It would desugar to instance Newtype RegexFlags {..}
There was a problem hiding this comment.
Ah of course. Damn, that's a big deal actually.
|
Looks good 👍 |
|
@paf31 any other comments before merge? (not meaning to hassle you with updates, I get that you're at work 😄 just wanted to double check) |
|
looks good! |
No description provided.