
#8477: Allow inferring ambiguous types -------------------------------------+------------------------------------ Reporter: aavogt | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: 8390 -------------------------------------+------------------------------------ Comment (by simonpj): I'm dubious about this * Accepting ''inferred'' ambiguous types is a recipe for planting land- mines that will only show up later. Requiring a type signature in such cases seems quite reasonable to me. * I tried [http://okmij.org/ftp/Haskell/TypeLambdaVal.hs]. The instance on line 199 seems problematic; it fails both the ambiguity check and the coverage condition. However I realise that the ambiguity check on the instance declaration should really subsume the (liberal) coverage condition. I'll fix that. * Then the `TypeLambdaVal` example gives {{{ T8477.hs:218:1: Could not deduce (Apply (HIF' (b0 -> HNothing) (HList (a0 :* xs0) -> HJust a0)) (HBool b, x) res) arising from the ambiguity check for ‛hsafe_head’ from the context (Apply HNull x (HBool b), Apply (HIF' (b1 -> HNothing) (HList (a :* xs) -> HJust a)) (HBool b, x) res) bound by the inferred type for ‛hsafe_head’: (Apply HNull x (HBool b), Apply (HIF' (b1 -> HNothing) (HList (a :* xs) -> HJust a)) (HBool b, x) res) => x -> res at T8477.hs:(218,1)-(221,24) The type variables ‛b0’, ‛a0’, ‛xs0’ are ambiguous When checking that ‛hsafe_head’ has the inferred type ‛forall x res b b1 a xs. (Apply HNull x (HBool b), Apply (HIF' (b1 -> HNothing) (HList (a :* xs) -> HJust a)) (HBool b, x) res) => x -> res’ Probable cause: the inferred type is ambiguous }}} and one other. Indeed, writing out that type may be a bit onerous, but it really does look ambiguous to me! So I'm inclined to "won't fix" for now. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8477#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler