make match safe#14
Conversation
There was a problem hiding this comment.
This type seems incorrect. Something like
forall r. Fn4 Regex String ([String] -> r) r r
makes more sense to me.
There was a problem hiding this comment.
This is one of the lines I copied without fully understanding. I'll update the type now.
There was a problem hiding this comment.
Updated. Could you explain ([String] -> r)?
There was a problem hiding this comment.
The type r in our case is Maybe [String], so Just and Nothing have type [String] -> Maybe [String] and Maybe [String] respectively. But looking at the code, there is nothing which uses the fact that the result is of type Maybe [String], all we care about is that
Just(m)andNothinghave the same type.Justtakes an argument of type[String]
so we can generalize the result type from Maybe [String] to r for all r.
There was a problem hiding this comment.
Terrific explanation! Thank you, @paf31.
|
Looks good, thanks. I put one comment on the code itself, though. |
|
Thanks 👍 Before making a release for this I'll check that there's nothing else that needs making safe, as this should be a new |
String.prototype.matchreturnsnullif there is no match. For example:This change is largely copied from #13.