[GHC] #11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks

GHC ghc-devs at haskell.org
Thu May 24 13:02:07 UTC 2018


#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep
leaks
-------------------------------------+-------------------------------------
        Reporter:  simonpj           |                Owner:  sighingnow
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  7.10.3
      Resolution:                    |             Keywords:
                                     |  LevityPolymorphism
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #13275, #15181    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by sighingnow):

 * owner:  (none) => sighingnow


Comment:

 I have looked into this ticket. This `:set -fprint-explicit-runtime-reps`
 **doesn't** work in ghc 8.0.1/8.0.2/8.2.2/8.4.2/head.

 -------------------------------------------------

 In IfaceType.hs, we use `pprIfaceSigmaType` to pretty print a type:

 {{{#!hs
 pprIfaceSigmaType :: ShowForAllFlag -> IfaceType -> SDoc
 pprIfaceSigmaType show_forall ty
   = ppr_iface_forall_part show_forall tvs theta (ppr tau)
   where
     (tvs, theta, tau) = splitIfaceSigmaTy ty
 }}}

 The kind signatures are not feed into `eliminateRuntimeRep` and
 `defaultRuntimeRepVars`. The `forall (r :: GHC.Types.RuntimeRep) a (b ::
 TYPE r)` is pretty printed by `pprUserIfaceForAll` (invoked by
 `ppr_iface_forall_part`).

 {{{#!hs
 pprUserIfaceForAll :: [IfaceForAllBndr] -> SDoc
 pprUserIfaceForAll tvs
    = sdocWithDynFlags $ \dflags ->
      -- See Note [When to print foralls]
      ppWhen (any tv_has_kind_var tvs
              || any tv_is_required tvs
              || gopt Opt_PrintExplicitForalls dflags) $
      pprIfaceForAll tvs
    where
      tv_has_kind_var (TvBndr (_,kind) _) = not (ifTypeIsVarFree kind)
      tv_is_required = isVisibleArgFlag . binderArgFlag
 }}}

 So, for `($)`, we always print `($) :: forall (r :: GHC.Types.RuntimeRep)
 a (b :: TYPE r) (a -> b) -> a -> b`.

 -----------------------------------------

 As for why `:t` and `:i` print different result, in
 f2a2b79fa8d1c702b17e195a70734b06625e0153, we instantiate deeply for
 `:type`, then `:t` and `:i` have different behaviour for `($)`. If we
 revert this commit, `:t ($)` will produce same result as `:i ($)`.

 ------------------------------------------------

 In ticket:11376#comment:34, Simon wrote:

 > OK, well we can both live with
 >
 > * `:type var` prints the original type of `var`, whereas `:type expr`
 typechecks, instantiates, and re-generalises the type of `expr`.
 >
 > > But how long will it be until someone posts a bug report complaining
 that `:t (blah)` is different from `:t blah`?
 >
 > Maybe not long, but we can just point to the user manual.  Having two
 commands is a pain when you can get the second by adding parens to the
 first.
 >
 > Now we just need someone to do it.

 I will try this and optimistically assign this ticket to myself.

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


More information about the ghc-tickets mailing list