Skip to content
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

Merged
merged 1 commit into from
May 9, 2017
Merged

phone-number 1.2.0.3: enforce area/exchange not starting with 1 #534

merged 1 commit into from
May 9, 2017

Conversation

petertseng
Copy link
Member

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


number :: String -> Maybe String
number input
| any isLetter input = Nothing
number input = clean input >>= check
Copy link
Member Author

@petertseng petertseng May 9, 2017

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.

Copy link
Contributor

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?

Copy link
Contributor

@rbasso rbasso left a 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. 👍

, 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"
Copy link
Contributor

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",

Copy link
Member Author

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.

, input = "(123) 456-7890"
, expected = Just "1234567890"
, input = "(223) 456-7890"
, expected = Just "2234567890"
}
, Case { description = "cleans number with dots"
Copy link
Contributor

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
petertseng added a commit that referenced this pull request May 9, 2017
* 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
@petertseng
Copy link
Member Author

And sorry @rbasso , but I'll need to ask for approval on this one again too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants