-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
phone-number 1.2.0.3: enforce area/exchange not starting with 1 #534
Conversation
|
||
number :: String -> Maybe String | ||
number input | ||
| any isLetter input = Nothing | ||
number input = clean input >>= check |
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.
pointfree.io tells me this is number = (check =<<) . clean
but I'm not sure I consider that better.
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.
You code is definitely clearer!
If I where to rewrite it, I would probably "point-free-fy it" with number = clean >=> check
, but it has the inconvenience of an additional import.
Does it type-checks?
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.
I'm enjoying your PRs, @petertseng. The links help a lot. 😄
I just noticed that some descriptions do not exactly match x-common
, but I don't think this it is a major problem.
Thanks for this one and all the other PRs. 👍
exercises/phone-number/test/Tests.hs
Outdated
, Case { description = "invalid when 11 digits" | ||
, input = "21234567890" | ||
, Case { description = "invalid when 11 digits does not start with a 1" | ||
, input = "22234567890" | ||
, expected = Nothing | ||
} | ||
, Case { description = "valid when 11 digits and first is 1" |
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.
"description": "valid when 11 digits and starting with 1",
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.
Since I have a case that says "starting with 1" later on, I might as well change this one to match. Coming right up.
exercises/phone-number/test/Tests.hs
Outdated
, input = "(123) 456-7890" | ||
, expected = Just "1234567890" | ||
, input = "(223) 456-7890" | ||
, expected = Just "2234567890" | ||
} | ||
, Case { description = "cleans number with dots" |
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.
Small difference from canonical-data.json
:
"description": "cleans numbers with dots",
1.0.1 and 1.0.2: description clarifications exercism/problem-specifications#719 exercism/problem-specifications#724 1.1.0: enforce area/exchange not starting with 1 exercism/problem-specifications#745 1.2.0: 1a2b3c4d5e6f7g8h9i0j removed exercism/problem-specifications#772 Closes #518
* bowling 1.0.0.2: drop unneeded rolls, edit a description * leap 1.0.0.2: explain criteria in descriptions, put in progress order * luhn 1.0.0.2: only test isValid, use (most) x-common cases * phone-number 1.2.0.3: enforce area/exchange not starting with 1 * roman-numerals 1.0.0.2: add descriptions
And sorry @rbasso , but I'll need to ask for approval on this one again too |
1.0.1 and 1.0.2: description clarifications
exercism/problem-specifications#719
exercism/problem-specifications#724
1.1.0: enforce area/exchange not starting with 1
exercism/problem-specifications#745
1.2.0: 1a2b3c4d5e6f7g8h9i0j removed
exercism/problem-specifications#772
Closes #518