[GHC] #9608: Type level as-patterns

GHC ghc-devs at haskell.org
Thu Sep 18 14:48:11 UTC 2014


#9608: Type level as-patterns
-------------------------------------+-------------------------------------
              Reporter:  danilo2     |            Owner:
                  Type:  feature     |           Status:  new
  request                            |        Milestone:
              Priority:  normal      |          Version:  7.9
             Component:  Compiler    |         Keywords:
  (Parser)                           |     Architecture:  Unknown/Multiple
            Resolution:              |       Difficulty:  Unknown
      Operating System:              |       Blocked By:
  Unknown/Multiple                   |  Related Tickets:
       Type of failure:              |
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------
Description changed by danilo2:

Old description:

> 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

New description:

 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 than the first one.
 (Safer in terms of accidental typos when refactoring etc).

 Cheers,
 Wojciech

--

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


More information about the ghc-tickets mailing list