Skip to content

Warning "Defaulting the following constraints to type Integer in leap_test.hs #143

@rbasso

Description

@rbasso

The years in leap_test.hs have no explicit type, allowing solutions with differente type signatures:

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

This is desirable, but has the unintended effect of displaying a 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 the most general solution:

isLeapYear :: Integral a => a -> Bool

It's important to supress 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 usually encouraged in Haskell.

I don't think it's possible to write a test allowing those three distinct signatures without raising a warning, so I propose to suppress it with:

{-# OPTIONS_GHC -fno-warn-type-defaults #-}

I could make a pull request for leap and maybe other exercises sharing the same problem, but I haven't checked yet how many they are.

Anyone against it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions