[GHC] #7015: Add support for 'static'

GHC ghc-devs at haskell.org
Sun Aug 17 16:36:43 UTC 2014


#7015: Add support for 'static'
-------------------------------------+-------------------------------------
              Reporter:  edsko       |            Owner:
                  Type:  feature     |           Status:  patch
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:  7.4.2
             Component:  Compiler    |         Keywords:
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:  Phab:D119   |
-------------------------------------+-------------------------------------

Comment (by facundo.dominguez):

 When trying to do floating in the desugarer I arrived at a point where I
 need evidence bindings to desugar. For instance, when encountering the
 expression `static return :: Ref (a -> IO a)`, the desugarer tries to
 float `return` as
 {{{
 Main.static:0 :: forall a_azE. a_azE -> GHC.Types.IO a_azE
 Main.static:0 =
   \ (@ a_azE) -> GHC.Base.return @ GHC.Types.IO $dMonad_azG @ a_azE
 }}}
 where `$dMonad_azG` is a variable carrying the `Monad IO` dictionary. As
 `$dMonad_azG` is not in scope the above code is rejected by the Core Lint
 pass.

 When floating is done in the typechecker, the binding of `$dMonad_azG` is
 produced by `simplifyInfer` in `checkStaticValues` at the place where the
 floated bindings for static forms are assembled. Further down the
 processing, desugaring inserts this evidence binding as a core `let`
 binding in the rhs of `static:0`, subsequently inlined to yield something
 like:
 {{{
 Main.static:0 :: forall a_azE. a_azE -> GHC.Types.IO a_azE
 Main.static:0 =
   \ (@ a_azE) -> GHC.Base.return @ GHC.Types.IO GHC.Base.$fMonadIO @ a_azE
 }}}
 Now, to do floating in the desugarer, it looks like evidence bindings need
 to be communicated to the place in the desugarer (I presume `dsExpr`)
 where the floating should be implemented. Would there be a preferred way
 to do it? I couldn't find precedents of similar needs in the ghc code.

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


More information about the ghc-tickets mailing list