
#12702: Don't warn about redundant constraints for necessary -------------------------------------+------------------------------------- Reporter: crockeea | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- 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.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12702 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler