[GHC] #12700: Don't warn about redundant constraints for type equalities
GHC
ghc-devs at haskell.org
Fri Oct 14 15:09:57 UTC 2016
#12700: Don't warn about redundant constraints for type equalities
-------------------------------------+-------------------------------------
Reporter: crockeea | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
I see
* `foo` really does have the type `(RealFrac a, Integral b) => a -> b`.
That is, as GHC claims, the constraint can simply be omitted.
* But you specifically want to write a less-polymorphic type than the most
general type. Another example might be
{{{
f :: Ord a => a -> a
f x = x
}}}
The `Ord a` is not needed, but you might want to require it for some
software engineering reason. That's your situation here, I believe.
* It's worth noting that you can certainly say
{{{
f :: [a] -> [a]
f x = x
}}}
thus specifying a less polymorphic type than the most general one,
without causing a warning of any kind.
This is one of the reasons that `-Wredundant-constraints` is no longer on
by default, and is not even enabled by `-Wall`. I'm a bit sad, but the
annoyance was too great.
The real solution would be a per-function pragma to say "I intend to have
a redundant constraint here".
If I've understood aright, then we need take no action, except add it as
another use-case for the per-function pragma
See #11370, #10635
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12700#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list