-
Notifications
You must be signed in to change notification settings - Fork 73
Add unsafeRegex #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unsafeRegex #74
Conversation
👍 Except that usually we separate unsafe functions into sub modules like |
Seems reasonable, requires another import though. The goal is mostly to reduce the amount of boilerplate needed for (poor man's) regex literals. |
-- | Constructs a `Regex` from a pattern string and flags. Fails with | ||
-- | an exception if the pattern contains a syntax error. | ||
unsafeRegex :: String -> RegexFlags -> Regex | ||
unsafeRegex s f = unsafePartial $ fromRight (regex s f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: there's no need for the $
here.
Yes, could we please move this into |
Probably should be |
Could possibly have a |
We already have a |
Well, kinda. Having a |
@garyb you mean eliminate the need for |
I meant if we had |
Yeah, it's the use of the function we want to make easier, not the definition. |
@garyb oh you meant: eliminate the need for |
I'll move the function to |
Great, thanks! |
Fixes #73.