[GHC] #8503: New GeneralizedNewtypeDeriving check still isn't permissive enough

GHC ghc-devs at haskell.org
Wed Nov 20 14:12:26 UTC 2013


#8503: New GeneralizedNewtypeDeriving check still isn't permissive enough
-------------------------------------+------------------------------------
        Reporter:  goldfire          |            Owner:  goldfire
            Type:  bug               |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:  7.7
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:  #8541
-------------------------------------+------------------------------------

Comment (by nomeata):

 Got that code in a working form. I don’t claim to know the solver well
 enough to be completely certain that there is not a way left to create a
 recursive dictionary, but at least the examples that I tried worked.
 Commits 6f5c183cb798a5d5e1011417f1f211834e4e9215 (GHC) and
 ec83ce7530af5474a3ad49d7120913c7f22266f0 (testsuite); for convenience,
 here is the note describing the design:

 {{{
 Note [Preventing recursive dictionaries]

 We have some classes where it is not very useful to build recursive
 dictionaries (Coercible, at the moment). So we need the constraint solver
 to
 prevent that. We conservativey ensure this property using the subgoal
 depth of
 the constraints: When solving a Coercible constraint at depth d, we do not
 consider evicence from a depth <= d as suitable.

 Therefore we need to record the minimum depth allowed to solve a CtWanted.
 This
 is done in the SubGoalDepth field of CtWanted. Most code now uses
 mkCtWanted,
 which initializes it to initialSubGoalDepth (i.e. 0); but when requesting
 a
 Coercible instance (requestCoercible in TcInteract), we bump the current
 depth
 by one and use that.

 There are two spots where wanted contraints attempted to be solved using
 existing constraints; doTopReactDict in TcInteract (in the general solver)
 and
 newWantedEvVarNonrec (only used by requestCoercible) in TcSMonad. Both use
 ctEvCheckDepth to make the check. That function ensures that a Given
 constraint
 can always be used to solve a goal (i.e. they are at depth infinity, for
 our
 purposes)
 }}}

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


More information about the ghc-tickets mailing list