[GHC] #15379: Don't reject user-written instances of KnownNat and friends in hsig files

GHC ghc-devs at haskell.org
Tue Jul 31 14:07:18 UTC 2018


#15379: Don't reject user-written instances of KnownNat and friends in hsig files
-------------------------------------+-------------------------------------
        Reporter:  ezyang            |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.4.3
      Resolution:                    |             Keywords:  backpack
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4988
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by ppk):

 As mentioned by @simonpj, it would be desirable to actually pinpoint how
 the dictionaries of
 `KnownNat` and friends get resolved in the context of backpack. This
 comment is more to document
 what I have learned by simply dumping the desugared version.

 I have attached a test backpack program (attachment:test.bkp) with the
 output after compiling with
 `-ddump-ds` and `-ddump-simpl`. The desugared version is avaliable in
 attachment:out-desugar

 One can clearly see that an the KnownNat instance is substituted for and
 the appropriate versions of Util is created
 [https://ghc.haskell.org/trac/ghc/attachment/ticket/15379/out-desugar#L58
 Line 56]
 and [https://ghc.haskell.org/trac/ghc/attachment/ticket/15379/out-
 desugar#L92 Line 92]. Although there is no trace of the Util module
 without the substitution, if we had no mixing-in there will
 also be a variant of Util with the abstract dictionary for `KnownNat
 NatType`.

 So my understanding would be that backpack is going ahead and "inlining"
 the dictionary when mixing a module that uses a abstract signature with a
 concrete implementation of that signature. I hope that makes sense.

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


More information about the ghc-tickets mailing list