-
Notifications
You must be signed in to change notification settings - Fork 361
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
Regex, runtime error #378
Comments
I think it makes sense for regex to be |
Yeah, it's either that or keep the runtime error. Most regexes won't be generated dynamically (in signals or functions), so there's a case for keeping the runtime error since it will be easier to work with the absence of a Result or Maybe. (We seem to be getting useful error messages, so I support a Result in the API.) |
In the spirit of these guidelines I've made a gist for a potentially interesting solution to this. Any discussion of that idea is welcome over on the gist itself, but let's not derail this issue with that stuff. 😄 |
Is this "the same" as https://github.com/elm-lang/core/issues/157? Should we close that other issue, then? |
I've created #380 that will change Perhaps leaving This would remove the need to introduce a new syntax as per rtfeldman's gist, though leave a runtime error possible. |
Regex literals might be a solution. That way invalid regexps are a compile time error |
That's been brought up before, and I agree would be a good solution. But it involves a compiler change, and you'd have to validate JS regexes in Haskell. |
For my (admittedly rare) usecase, I'm creating regular expressions based on user input, in order to filter a list and extract results with matching groups - so unfortunately a literal syntax only would make that usecase more difficult - right now I'm porting from a JavaScript version which uses Returning a |
Consolidated regex stuff in #722. Follow along there! |
The plan is to move regular expressions to fromString : String -> Result String RegExp As seen here: https://github.com/evancz/regexp/blob/master/src/RegExp.elm#L44 |
In core package, module Regex
This function can produce runtime error if string contain invalid pattern.
Here is an example form elm-repl
It would be better if we change regex to be
it will return
Nothing
if string contains invalid pattern.The text was updated successfully, but these errors were encountered: