-
Notifications
You must be signed in to change notification settings - Fork 73
Use unsafeCrashWith for unsafeRegex (future fromEither not Partial) + Unix line endings #128
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
Conversation
I suggest splitting this into two pull requests, @toastal, to make the significant changes more apparent in the diff. :) |
This PR is as draft while I can figure out what's going out with |
I think |
Then again, adding a Partial constraint to unsafeRegex could upset a few people, and might not provide much additional safety if it’s mostly only used at sites where you’d want the constraint to be unsafely discharged anyway (which I suspect is the case). |
Note, you can't actually use this due to strictness. This will just crash immediately. |
Do people use anything but |
To be honest, I don't think I've ever used regexes in PureScript in any form. |
I think sensible recovery is possible and indeed necessary if you're constructing a regex based on user input or any other data obtained at runtime. Also, just because there's no sensible way of recovering from an invalid regex constructed from a string literal, it doesn't mean a Partial constraint isn't appropriate - in fact I'd say Partial constraints are only for cases where there's no sensible way of recovering. The point of it is just to indicate that the caller needs to be careful, and to give you the option to either discharge it (if the partiality has been dealt with) or propagate it if not. |
FWIW I think we already had this discussion when we added |
I agree with not adding a Partial constraint, I just wanted to point out that, imo, not having a sensible way of recovering doesn't justify omitting a Partial constraint in general. For me, the reason not to do it is that it makes the ergonomics terrible, and it doesn't provide very much safety because 99% of the time you would want to discharge the Partial constraint immediately anyway. |
Not sure how to add a |
We don’t store changelog files in the core libraries, we just look over the commit log and add release notes along with each release in GitHub, so no action needed there. There’s also no action needed re dependencies since what you have here will work with both old and new versions of either. When we get around to updating this library properly we will update everything to master temporarily, but that’s not necessary just yet. |
Can you show what the errors look like now? |
@hdgarrood For |
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.
Works for me. Thanks!
:'( ... I really wanted to be a contributor |
The future version of
Data.Either.fromRight
is no longerPartial
, sofromJust ∘ hush
is a way around this asfromJust
is still Partial but not ideal.Alternatively,.Data.Either
should have likeData.Either.Partial.fromRight
to restore previous behavior (closes either #56)It was decided that it would be better to
unsafeCrashWith
on theLeft
-hand side of Regex instantiation.Seemed really out of place to have one file with DOS line endings. Also, purty was run on this.