-
Notifications
You must be signed in to change notification settings - Fork 75
Closed
Description
match currently has the following type:
match :: Regex -> String -> Maybe [String]This is problematic, though, when one considers optional capturing groups:
> 'goodbye'.match(/(good)?bye/)
['goodbye', 'good']
> 'bye'.match(/(good)?bye/)
['bye', undefined]Perhaps the function's type should be Regex -> String -> Maybe [Maybe String]. This would make the function cumbersome in the case of a pattern with no capturing groups: matching /hello/ would either give Nothing or Just([Just("hello")]).
This is an example of a dynamically typed language allowing a function to do too many things. Now we have the unenviable job of making sense of it all. :)
Metadata
Metadata
Assignees
Labels
No labels