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

GHC ghc-devs at haskell.org
Mon Jan 4 19:59:54 UTC 2016


#11350: Allow visible type application in patterns
-------------------------------------+-------------------------------------
           Reporter:  Iceland_jack   |             Owner:
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.1
           Keywords:                 |  Operating System:  Unknown/Multiple
  TypeApplications PatternSynonyms   |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Constructors (and pattern synonyms) when treated as expressions may be
 applied to types:

 {{{#!hs
 {-# LANGUAGE TypeApplications #-}

 Nothing     :: Maybe a
 Nothing @() :: Maybe ()

 pattern Pair :: a -> a -> (a, a)
 pattern Pair x y = (x, y)

 Pair      :: a   -> a   -> (a, a)
 Pair @Int :: Int -> Int -> (Int, Int)
 }}}

 But using them in patterns won't parse:

 {{{#!hs
 -- parse error in pattern: @Int
 maybeToList :: Maybe Int -> [Int]
 maybeToList (Nothing @Int) = []
 maybeToList (Just @Int x)  = [x]

 -- parse error in pattern: @Int
 add :: (Int, Int) -> Int
 add (Pair @Int x y) = x + y
 }}}

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


More information about the ghc-tickets mailing list