[GHC] #9582: Associated Type Synonyms do not unfold in InstanceSigs

GHC ghc-devs at haskell.org
Tue Sep 23 09:33:36 UTC 2014


#9582: Associated Type Synonyms do not unfold in InstanceSigs
-------------------------------------+-------------------------------------
              Reporter:              |            Owner:
  andreas.abel                       |           Status:  patch
                  Type:  bug         |        Milestone:
              Priority:  normal      |          Version:  7.8.3
             Component:  Compiler    |         Keywords:  InstanceSigs
  (Type checker)                     |  TypeFamilies
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 I'm sorry about being slow to reply -- utterly swamped.

 >    2. 'tcSubType' does not generate errors, just postponed
 > constraints, which are checked later in a clean-up phase.  Thus, I do
 > not get an error now I could handle, but the error is generated later
 > during the constraint solving phase, where I do not have a handler in
 place.

 This is dead right, and I think it's a huge strength of GHC's current type
 inference mechanism.  Essentially all type error messages are generated in
 `TcErrors`, not in places scattered over the compiler.  This is not a
 "clean-up phase".  It is ''the'' place that type errors are generated.

 For `tcSubType`, the way to control your error messages is through the
 `CtOrigin` and `UserTypeCtxt` passed to `tcSubType`.

 The `UserTypeCtx`t is attached (via the ic_info field of `Implication`) to
 the implication constraint generated by the `tcSubType`.  If you want, you
 can add an extra constructor to `UserTypeCtxt`.

 The `CtOrigin` is attached to the instantiated constraints generated by
 the sub-type check.

 Both are accessible to the error-message generation in `TcErrors`.

 In short, instead of catching the error(s) ''now'', GHC just attaches
 enough information to the constraints that you can generate a good error
 message later.

 I hope that is of some help.

 Simon

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


More information about the ghc-tickets mailing list