[GHC] #15050: ScopedTypeVariables could allow more programs

GHC ghc-devs at haskell.org
Tue Apr 17 19:11:21 UTC 2018


#15050: ScopedTypeVariables could allow more programs
-------------------------------------+-------------------------------------
        Reporter:  nomeata           |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.4.1
      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 goldfire):

 This is a consequence of the fact that a scoped type variable must be a
 variable, never a type. Another way of saying this is that a type variable
 brought into scope in a pattern type annotation simply names an existing
 type variable; it can't, say, bind a type variable to a type.

 Of course, with type equalities (and therefore GADTs), you can have a type
 variable `a` and the constraint `a ~ Int`. In this case, you ''can'' bind
 a scoped type variable to `a`, despite the equality constraint saying that
 you're essentially binding a scoped type variable to a type.

 I've personally never liked this design choice around scoped type
 variables, believing that a pattern-bound type variable should be able to
 be bound to any type. The lack of ability to do this has actually been a
 pain point in `singletons` from the beginning, and these examples show
 that the current behavior isn't even truly self-consistent.

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


More information about the ghc-tickets mailing list