[GHC] #12643: class declaration works in ghci, but not in a file

GHC ghc-devs at haskell.org
Fri Sep 30 10:26:59 UTC 2016


#12643: class declaration works in ghci, but not in a file
-------------------------------------+-------------------------------------
        Reporter:  dmwit             |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Crumbs.  This is another variation of #11348, and its as-yet-unsolved
 cousin #12088.

 In this case, we must type check in this order:

 1. `deriving instance Generic (ExceptT e m a)`.  This generates a `type
 instance Rep (Except e m a) = ...` declaration, for `Generic`'s associated
 type `Rep`.

 2. `class F a where ...`.  We must do this second because `f`'s type can
 be seen to be unambiguous only after expanding the call to `Rep`.

 However the fix to #11348 arranges to interleave `type instance`
 declarations with type/class decls; but `deriving instance` declarations
 are still left to the end.  The fix is, I think, to include `deriving
 instance` decls in the interleaving.

 Workaround for now: make the staging explicit with a degenerate Template
 Haskell splice, thus:
 {{{
 deriving instance Generic (ExceptT e m a)

 $( return [] )    -- Degenerate splice

 class F a where f :: Rep (Except String a) x
 }}}

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


More information about the ghc-tickets mailing list