Skip to content

Don't warn about redundant constraints for necessary

In the attached example, GHC warns that the constraint on line 16 of Main.hs is redundant.

• Redundant constraint: e ~ FGCD r s
• In the type signature for:
    foo :: (e ~ FGCD r e', e' ~ (e * (s / r)), e ~ FGCD r s) =>
            Proxy s -> Proxy r -> ()

However, when I remove that constraint, I get the following error:

• Occurs check: cannot construct the infinite type:
    t0 ~ Factored.FMul (FGCD r t0) (Factored.FDiv s r)
  The type variable ‘t0’ is ambiguous
• In the ambiguity check for ‘foo’
  To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
  In the type signature:
    foo :: forall e e' r s.
           (e ~ FGCD r e', e' ~ (e * (s / r))) => Proxy s -> Proxy r -> ()

I'm not entirely sure if the error is correct or not; I can't figure out what it's getting on about.

So: if the constraint is required to make foo compile, then it is most certainly not redundant, and there shouldn't be a warning suggesting its removal. If the constraint really isn't required, then the error is a bug.

(I apologize for the second bug involving singletons in as many days; I simply don't know an easy way to remove that dependency.)

Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information