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

Add -fno-warn-type-defaults to supress unwanted warnings. #144

Merged
merged 1 commit into from
Jun 17, 2016
Merged

Add -fno-warn-type-defaults to supress unwanted warnings. #144

merged 1 commit into from
Jun 17, 2016

Conversation

rbasso
Copy link
Contributor

@rbasso rbasso commented Jun 8, 2016

In some problems, like leap, the test module doesn't declare explicitly some numeric types, allowing solutions with multiple types:

isLeapYear :: Int     -> Bool
isLeapYear :: Integer -> Bool

This is desirable, but has the unintended effect of displaying the warning...

Defaulting the following constraint(s) to type `Integer` arising from the use of `isLeapYear` at leap_test.hs ... arising from the literal 1996 ...

... when compiling leap_test.hs with polymorphic solutions:

isLeapYear :: Integral a => a -> Bool

It's important to suppress this warning so we don't misguide newcomers in thinking that there is something wrong with their code, when the problem is in the test module. Also, using the most general type is actually encouraged in Haskell.

It's desirable to have test modules that compile silently. This would benefit users and automated tests, that could be compiled with -Wall -Werror.

Affected problems:

  • grains
  • hamming
  • leap
  • pascals-triangle
  • scrabble-score
  • sieve
  • sum-of-multiples

Proposed solution: Add {-# OPTIONS_GHC -fno-warn-type-defaults #-} to the affected modules.

Closes #143

@rbasso
Copy link
Contributor Author

rbasso commented Jun 11, 2016

Just to make it clear, the list of affected problems is probably not complete, as it would demand inspection of all exercises individually. These are the ones I identified running my last iteration of each exercise, but not all of my solutions are polymorphic as to force exhibition of the warning.

Anyway, the solution for any new appearing warning of that type would be exactly the same.

This PR will probably conflict with #146 .

Supress "Defaulting the following constraints to type Integer"
warning when compiling the test modules with polymorphic solutions.

Affected problems:
    grains
    hamming
    leap
    pascals-triangle
    scrabble-score
    sieve
    sum-of-multiples
@petertseng
Copy link
Member

I noted in #143 that this is desirable (for the reasons listed in that issue and in this PR description). I would even support merging this as-is before I get a chance to investigate. I say this because I honestly think we may be in a "your guess is as good as mine" situation so if you couldn't find anything it's possible I wouldn't either. If I do find a better solution it's always possible for me to make another PR, so not really necessary to hold this one up!

@petertseng
Copy link
Member

The thing I didn't check thoroughly would be "is there any exercise you missed", but I'm sure we can fix that up easily if that is the case. Seems to require going through the entire list of exercises, not an easy way to grep for something that would be indicative...

@rbasso rbasso merged commit 2bca317 into exercism:master Jun 17, 2016
@rbasso rbasso deleted the fno-warn-type-defaults branch July 1, 2016 00:27
This was referenced Sep 20, 2017
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