Skip to content

grains: Change return type to Maybe#197

Merged
rbasso merged 1 commit intoexercism:masterfrom
rbasso:grains-change-return-to-maybe
Jul 13, 2016
Merged

grains: Change return type to Maybe#197
rbasso merged 1 commit intoexercism:masterfrom
rbasso:grains-change-return-to-maybe

Conversation

@rbasso
Copy link
Copy Markdown
Contributor

@rbasso rbasso commented Jul 12, 2016

Currently, the exercise grains has a function square :: Int -> Integer that returns the number of grains of wheat on sequentially numbered squares on a chessboard. The problem doesn't specify what should be returned if the number given is not in the chessboard.

This is a great opportunity to make it more idiomatic and get the users acquainted with Maybe.
I propose to to the following:

  1. Change the return type of function square from an Integer to a Maybe Integer.
  2. Add three test:
    • square (-1)
    • square 0
    • square 65
  3. Add a stub solution.

Change the return type of function `square` from an `Integer` to a
`Maybe Integer`.

Add three test:

- `square (-1)`
- `square   0 `
- `square  65 `

Add a stub solution.
@petertseng
Copy link
Copy Markdown
Member

Change seems good here, 👍

Might be good to see if this should be specified in x-common?

@rbasso
Copy link
Copy Markdown
Contributor Author

rbasso commented Jul 13, 2016

Maybe we don't need to change there:

  • There is no mention in exercism/x-common/grains.md about values out of the board.
  • There is no exercism/x-common/grains.json.

Should we write something in exercism/x-common/grains.md?

@petertseng
Copy link
Copy Markdown
Member

Yeah we can see if other tracks might want to check for out of bounds values like here. Maybe they'll like it, in which case it can be standard for all tracks. Or maybe they won't, an argument against might be exercism/problem-specifications#287 (comment) , but that means it'll just be a specific characteristic of this track.

@rbasso
Copy link
Copy Markdown
Contributor Author

rbasso commented Jul 13, 2016

I think that grains.md is good enough the way it is, but I understand that it would be nice to exposed the other tracks to out-of-bound cases. Maybe a exercism/x-common/grains.json marking the out-of-bound cases as implementation specific could be the solution.

@rbasso rbasso merged commit 90133ae into exercism:master Jul 13, 2016
@rbasso rbasso deleted the grains-change-return-to-maybe branch July 13, 2016 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants