#3043: An unrelated definition monomorphizes a type even without the MR
----------------------------------------+-----------------------------------
    Reporter:  Deewiant                 |        Owner:                  
        Type:  bug                      |       Status:  closed          
    Priority:  normal                   |    Milestone:                  
   Component:  Compiler (Type checker)  |      Version:  6.10.1          
    Severity:  normal                   |   Resolution:  invalid         
    Keywords:                           |   Difficulty:  Unknown         
    Testcase:                           |           Os:  Unknown/Multiple
Architecture:  Unknown/Multiple         |  
----------------------------------------+-----------------------------------
Changes (by simonpj):

  * status:  new => closed
  * difficulty:  => Unknown
  * resolution:  => invalid

Comment:

 Your final remark isn't right in general.  Consider:
 {{{
 f x = let y = x::Int
       in x && True
 }}}
 This is rejected, because `x` can't be both an `Int` and a `Bool`.  But
 it'd be accepted if the binding for `y` was dropped. The type checker
 takes no notice of whether `y` is mentioned or not.  (You might want it
 to, but I don't think it matters one way or the other in practice.)

 In your example, since `a` and `b` are both mentioned in the right hand
 side of `x`, the type of `x` can't be generalised.  Suppose `a :: ta` and
 `b :: tb`. Then the inferred type for `x` will be something like
 {{{
   x :: forall c. Id ta c => (c, tb)
 }}}
 Now the type sig in `y` instantiates `c` to `String`, forces `tb=Int`, and
 generates a constraint `(Id ta String)`.  Now the fundep on `Id` forces
 `ta=String`.

 That's as far as I have time to go today. I don't think this has anything
 to do with the MR.

 Reopen if you disagree.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3043#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to