[GHC] #13754: ghc-8.0.2+ rejects more instance declarations

GHC ghc-devs at haskell.org
Thu May 25 14:43:44 UTC 2017


#13754: ghc-8.0.2+ rejects more instance declarations
-------------------------------------+-------------------------------------
        Reporter:  zilinc            |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.2
      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):

 The error message is not great, but here is what is happening.  The
 default method in the class decl generates
 {{{
 $dmpretttyList :: forall a. Pretty a => [a] -> SDoc
 $dmprettyList = concatMap pretty
 }}}
 That seems reasonable.  Now in the instance decl it's as if you had
 written
 {{{
 instance (Pretty (e t)) => Pretty (Def e) where
   pretty = ...
   prettyList = $dmprettyList @(Def e)
 }}}
 From the call to `$dmprettyList` we get a "wanted" constraint `Pretty (Def
 e)`.
 That simplifies, via the instance decl itself, to `Pretty (e t0)`, where
 `t0` is a fresh unification varaible.
 Hence the message you see.

 But your instance declaration is deeply strange anyway, becuase the `t` is
 completely unconstrained.  Having a "given" `(Pretty (e t)` isn't much use
 if we know nothing about `t`.  (There is nothing wrong with the class,
 just the instance.)

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


More information about the ghc-tickets mailing list