
#10675: GHC does not check the functional dependency consistency condition correctly -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: FunDeps Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by AntC): Some afterthoughts: * What if the instances from the O.P. were declared in separate modules? Then GHC couldn't apply the mutual improvement. Would it reject the instances as inconsistent? * I find the statement of '''Definition 6''' in the CHR paper a bit imprecise. Mark Jones 2000 paper is clearer [Section 6.1]. It says "if `tX` and `sX` have a most general unifier `U`, then `UtY = UsY`." where `tX, sX` are the determinant types from the instance decl, `tY, sY` are the dependents. * I wonder if what GHC is doing to apply that test is rather than `UtY = UsY`, it's checking `UtY ~ UsY` -- that is, checking unifiability rather than equality(?) That would explain the behaviour with the `TTypeEq` examples. * Re the "dysfunctional" Functional Dependencies ;-), we could do with some better way of writing instances to give maximum help for type improvement. Currently you keep running up against instance-FunDep conflicts. And I don't think Injective type functions help much. For example type-level `Plus` over `Nat`s, with three-way FunDeps. [Yes I know Oleg worked it out years ago, but it's a ''tour de force''.] -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10675#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler