[GHC] #11387: Typecasting using type application syntax

GHC ghc-devs at haskell.org
Sat Jan 9 10:05:19 UTC 2016


#11387: Typecasting using type application syntax
-------------------------------------+-------------------------------------
           Reporter:  Iceland_jack   |             Owner:
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:
           Keywords:                 |  Operating System:  Unknown/Multiple
  TypeApplications                   |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:  #11350
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I created #11350 to allow visible (static) type applications in patterns.
 I had a [https://ghc.haskell.org/trac/ghc/ticket/11350#comment:2 thought]
 about translating non-parametric type applications in patterns as a
 runtime type check (`Typeable`) and decided to create a ticket in case it
 made any sense. Example:

 {{{#!hs
 doubleWhenInt :: forall a. Typeable a => a -> a
 doubleWhenInt x =
   case eqT @Int @a of
     Just Refl -> x + x
     Nothing   -> x

 -- Becomes…
 doubleWhenInt :: Typeable a => a -> a
 doubleWhenInt @Int n = n + n
 doubleWhenInt @_   x = x
 }}}

 Thoughts?

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


More information about the ghc-tickets mailing list