[GHC] #9110: MonomorphismRestriction too eager

GHC ghc-devs at haskell.org
Wed May 14 21:57:32 UTC 2014


#9110: MonomorphismRestriction too eager
-------------------------------------+------------------------------------
        Reporter:  goldfire          |            Owner:
            Type:  bug               |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:  7.8.2
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by simonpj):

 Here is what is happening:

  * `baz` gets the type `forall b. b -> alpha`, where `alpha` is a
 unification variable, plus a `Num alpha` constraint.  The MR prevents us
 generalising the `alpha`.

  * Because `baz` is bitten by the MR, it is not considered "closed"; see
 [http://www.haskell.org/ghc/docs/7.8.2/html/users_guide/other-type-
 extensions.html#monomorphism 7.13.9.3 in the user manual].  Actually the
 user manual is badly framed here.  It should say "A binding is considered
 closed if (a) all its free variables are imported or closed, and (b) it is
 unaffected by the monomorphism restriction."

  * Because `baz` is not closed, and `bar` mentions `baz`, `bar` is not
 closed.  Since `LocalMonoBinds` is force, `bar` is not generalised.

  * Since `bar` is not genrealised, `foo` really is not as polymorphic as
 its type signature claims.

 I'll fix the user manual, but otherwise things are working fine

 Simon

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9110#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list