• simonpj@microsoft.com's avatar
    Improve handling of implicit parameters · 2e9952b7
    simonpj@microsoft.com authored
    A message to Haskell Cafe from Grzegorz Chrupala made me realise that
    GHC was not handling implicit parameters correctly, when it comes to
    choosing the variables to quantify, and ambiguity tests.  Here's the 
    note I added to TcSimplify:
    Note [Implicit parameters and ambiguity] 
    What type should we infer for this?
    	f x = (show ?y, x::Int)
    Since we must quantify over the ?y, the most plausible type is
    	f :: (Show a, ?y::a) => Int -> (String, Int)
    But notice that the type of the RHS is (String,Int), with no type 
    varibables mentioned at all!  The type of f looks ambiguous.  But
    it isn't, because at a call site we might have
    	let ?y = 5::Int in f 7
    and all is well.  In effect, implicit parameters are, well, parameters,
    so we can take their type variables into account as part of the
    "tau-tvs" stuff.  This is done in the function 'FunDeps.grow'.
    The actual changes are in FunDeps.grow, and the tests are
    	tc219, tc219
TcSimplify.lhs 88.3 KB