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

Shouldn't all exercises have ghc-options: -Wall in their package.yaml? #769

Closed
sshine opened this issue Nov 15, 2018 · 2 comments
Closed

Comments

@sshine
Copy link
Contributor

sshine commented Nov 15, 2018

In Space Age I argue in my mentor feedback that one benefit of writing a total function,

orbitalPeriod :: Planet -> Float
orbitalPeriod Mercury = ...
orbitalPeriod Venus = ...
...

is that GHC can warn you in case of missing or duplicate cases, and that this is useful when extending data types over time. But if you add a planet and forget to extend orbitalPeriod, stack test and stack build will not, actually, show this warning.

Which made me think, why don't we add ghc-options: -Wall to package.yaml of all exercises?

@petertseng
Copy link
Member

Yes, not only is this a good idea on its own merits, the history supports it as well because exercism/exercism#804 added -Wall to the then-instructions. It seems that was lost on the move to Stack.

@sshine
Copy link
Contributor Author

sshine commented Nov 21, 2018

I've removed ghc-options: -Wall from all example package.yaml. Before the amend:

$ git diff-tree --no-commit-id --name-only -r HEAD | wc -l
201

$ git diff-tree --no-commit-id --name-only -r HEAD | grep examples | wc -l
105

After the amend:

$ git diff-tree --no-commit-id --name-only -r HEAD | wc -l
96

$ git diff-tree --no-commit-id --name-only -r HEAD | grep examples | wc -l
0

As 96 + 105 = 201, it seems that no other files were affected.

(Actually, I did accidentally commit a rogue file and found it by doing this test. Hooray!)

@sshine sshine closed this as completed in 3686cf4 Nov 22, 2018
sshine added a commit that referenced this issue Mar 12, 2019
* binary-search: Add exercise (closes #615)

Finishing @samosaara's work, this implements the binary-search exercise
on the Haskell track using `Data.Array` from the `array` package. This
seems to be the preferred choice cf. the discussion at #615.

In addition, a number of changes were made:

 - Unlock this after `collatz-conjecture` as the exercise deals with
   `Maybe`; placing it after the first exercise that deals with error
   handling seems natural.

 - Set exercise version number to 1.3.0.0 and update test suite. This
   addresses exercism/problem-specifications#1399 (version 1.3.0).

 - Add `ghc-options: -Wall` since #769.

 - Export function as `find`. This is what problem-specification calls it.

 - Generalise type signature in stub to better distinguish the type
   parameter for the index and the type parameter for the elements.
   One could generalise `Int` to `Ix i => i`, but this becomes slightly
   difficult when doing index arithmetic.

 - Make example solution work for arbitrary array bounds. Add test
   cases specific to the Haskell track that tests non-zero bounds.
   These cannot be expressed in problem-specifications right now, and
   they're only relevant for languages that can change the array base.

 - Add hint for optionally dealing with non-zero bounds.

 - Add hint with resources to `Data.Array`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants