
#13490: Ambiguous types with constraints on new variables -------------------------------------+------------------------------------- Reporter: crockeea | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: worksforme | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj):
Why am I getting an ambiguous type error
The "ambiguous type" check works like this. Suppose we have {{{ foo :: ty foo = blah }}} When is foo's type ambiguous? Answer: consider {{{ foo2 :: ty foo2 = foo }}} Does `foo2` typecheck OK? If not, `foo`'s type is ambiguous. Classic example {{{ foo :: (Read a, Show a) => String -> String foo x = show (read x) foo2 :: (Read a, Show a) => String -> String foo2 = foo -- Error! }}} Now in your case we try {{{ foo2 :: (Typeable (C z), z ~ Foo zp) => C zp foo2 = foo }}} and it's this check (i.e. precisely the ambiguous-type test) that fails. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13490#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler