[GHC] #9608: Type level as-patterns

GHC ghc-devs at haskell.org
Thu Sep 18 14:47:37 UTC 2014


#9608: Type level as-patterns
-------------------------------------+-------------------------------------
       Reporter:  danilo2            |                   Owner:
           Type:  feature request    |                  Status:  new
       Priority:  normal             |               Milestone:
      Component:  Compiler (Parser)  |                 Version:  7.9
       Keywords:                     |        Operating System:
   Architecture:  Unknown/Multiple   |  Unknown/Multiple
     Difficulty:  Unknown            |         Type of failure:
     Blocked By:                     |  None/Unknown
Related Tickets:                     |               Test Case:
                                     |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
 Hello! I would love to see type level as-patterns in Haskell. They would
 be very helpfull when writing complex type families. Here is a good
 example:

 {{{
 #!haskell
 type family XOut m1 m2 where
     XOut (ValueS vbase vs) (MonadCtx2Dummy' m2 s2 env set m s) =
 MonadCtx2Dummy' m2 s2 (XEnv env (ValueS vbase vs)) (XSet set (ValueS vbase
 vs)) m (XSafety s (ValueS vbase vs))
 }}}

 could then be written as:

 {{{
 #!haskell
 type family XOut m1 m2 where
     XOut a@(ValueS vbase vs) (MonadCtx2Dummy' m2 s2 env set m s) =
 MonadCtx2Dummy' m2 s2 (XEnv env a) (XSet set a) m (XSafety s a)
 }}}

 which is much cleaner, less verbose and lot safer then the first one.
 (Safer in terms of accidental typos when refactoring etc).

 Cheers,
 Wojciech

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


More information about the ghc-tickets mailing list