[GHC] #11350: Allow visible type application in patterns

GHC ghc-devs at haskell.org
Tue Sep 27 22:06:51 UTC 2016


#11350: Allow visible type application in patterns
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.1
      Resolution:                    |             Keywords:
                                     |  TypeApplications PatternSynonyms
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #11385            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Iceland_jack):

 Use case: with [https://hackage.haskell.org/package/array-0.5.1.1/docs
 /Data-Array-MArray.html#v:newListArray newListArray]

 {{{#!hs
 newListArray :: (MArray a e m, Ix i) => (i, i) -> [e] -> m (a i e)
 }}}

 we want to pick an instance of `MArray` many of whom have this form

 {{{#!hs
 instance MArray (STUArray s) Word  (ST s)
 instance MArray (STUArray s) Int   (ST s)
 instance MArray (STUArray s) Float (ST s)
 instance MArray (STUArray s) Bool  (ST s)
 }}}

 so you try

 {{{#!hs
 newListArray @(STArray _s1) @Bool @(ST _s2) @Int
   :: MArray (STArray t) Bool (ST t1)
   => (Int, Int)
   -> [Bool]
   -> ST t1 (STArray t Int Bool)
 }}}

 but we need to unify `_s1` and `_s2` if we want to discharge the
 constraint, using syntax from ticket:11385#comment:2

 {{{#!hs
 \ @s -> newListArray @(STArray s) @Bool @(ST s) @Int
 }}}

 the alternative being `newListArray @(STArray s) @Bool @(ST s) @Int ::
 forall s. _` (which isn't that bad because there are no additional
 constraints: if we had left `@Int` off it would not work and we would have
 to write

 {{{#!hs
 newListArray @(STArray s) @Bool @(ST s) :: forall s i. Ix i => (i, i) -> _
 }}}

 instead)

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


More information about the ghc-tickets mailing list