[GHC] #14917: Allow levity polymorhism in binding position

GHC ghc-devs at haskell.org
Wed Mar 14 13:38:06 UTC 2018


#14917: Allow levity polymorhism in binding position
-------------------------------------+-------------------------------------
        Reporter:  andrewthad        |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.2
      Resolution:                    |             Keywords:
                                     |  LevityPolymorphism
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 goldfire):

 I actually think this is a good idea.

 Simon's right in that figuring out exactly when you can inline can be
 tricky. But this logic is already in the compiler (in the inliner!) and so
 we can perhaps work it into the desugarer (which is where levity-
 polymorphism errors are issued). It's possible we'll have a hard time
 producing sensible error messages, but I think we'll be able to surmount
 that challenge.

 As to the proof: I'm not concerned. The proof is about Core. The proposed
 change wouldn't affect Core at all. Core still wouldn't have levity-
 polymorphic binders. (Unfoldings might, but not actual Core programs that
 will be compiled.) We can think of this proposal as suggesting "function
 templates", where these templates are stand-ins for a (perhaps infinite)
 family of levity-monomorphic functions.

 The implementation of this would be fiddly, but I don't see any true
 obstacles to it. And it does seem very silly that users can't reuse their
 typing for a function as simple as `twice`.

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


More information about the ghc-tickets mailing list