purescript / purescript-strings

String utility functions, Char type, regular expressions.
BSD 3-Clause "New" or "Revised" License
54 stars 71 forks source link

Add unsafeRegex #74

Closed rightfold closed 7 years ago

rightfold commented 7 years ago

Fixes #73.

LiamGoodacre commented 7 years ago

👍 Except that usually we separate unsafe functions into sub modules like Data.String.Regex.Unsafe or Data.String.Regex.Partial.

rightfold commented 7 years ago

Seems reasonable, requires another import though. The goal is mostly to reduce the amount of boilerplate needed for (poor man's) regex literals.

paf31 commented 7 years ago

Yes, could we please move this into Data.String.Regex.Partial? Looks good otherwise.

garyb commented 7 years ago

Probably should be Data.String.Regex.Unsafe in this case, since there's no partial constraint?

LiamGoodacre commented 7 years ago

Could possibly have a Partial version too/instead.

garyb commented 7 years ago

We already have a Partial version - that's the normal version :smile:, this is a convenience to avoid that.

garyb commented 7 years ago

Well, kinda. Having a Partial verison would eliminate the need for fromRight, but that's not really much better.

LiamGoodacre commented 7 years ago

@garyb you mean eliminate the need for unsafePartial, right? The fromRight is what would make this need a Partial constraint.

garyb commented 7 years ago

I meant if we had Partial => String -> RegexFlags -> Regex you'd still end up having to always unsafePartial for the case in the linked issue, so just providing a fully unsafe version is the only way to avoid the annoyance :)

rightfold commented 7 years ago

Yeah, it's the use of the function we want to make easier, not the definition.

LiamGoodacre commented 7 years ago

@garyb oh you meant: eliminate the need for fromRight on use, not on definition

rightfold commented 7 years ago

I'll move the function to .Unsafe.

paf31 commented 7 years ago

Great, thanks!