
#9627: Type error with functional dependencies -------------------------------------+------------------------------------- Reporter: augustss | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): Indeed. Here is a more direct example: {{{ class C a b | a -> b instance C Int Bool f :: C Int b => b -> Bool f x = x }}} From which we get {{{ Foo.hs:9:7: Could not deduce (b ~ Bool) from the context (C Int b) }}} Remember that GHC elaborates the program into System FC, generating evidence. * For type families, we know how to elaborate the program with proper, abstractable evidence in System FC * For functional dependencies I have no clue what evidence might look like. All GHC does (and all Hugs does) is to generate extra unification constraints; think of them as hints to guide the choice of how to instantiate unification variables. In the exmaple above there are no unification variables, so these hints do nothing, and the program is rejected. It's the same with your larger example. If someone can explain how to elaborate functional dependencies into well- typed evidence in System FC, that would be good. My inability to do so was one of the reasons we developed type families and System FC in the first place. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9627#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler