[GHC] #11461: Allow pattern synonyms to be bundled with type classes?

GHC ghc-devs at haskell.org
Tue Jan 19 16:18:16 UTC 2016


#11461: Allow pattern synonyms to be bundled with type classes?
-------------------------------------+-------------------------------------
           Reporter:  mpickering     |             Owner:
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  7.10.3
           Keywords:                 |  Operating System:  Unknown/Multiple
  PatternSynonyms                    |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 One can very nearly get associated pattern synonyms by defining suitably
 polymorphic pattern synonyms. However, they are not quite associated as
 there's no way to bundle them with the class. This isn't as good as
 "proper" support but it would be an easy thing to implement for now if
 people think it worthwhile.

 For a concrete example, `Null` is an associated pattern synonym in this
 style but the following program doesn't compile because it is disallowed
 to bundle a pattern synonym with a type class.

 {{{
 {-# LANGUAGE PatternSynonyms #-}

 module Foo(Nullable(Null)) where

 import Data.Maybe

 class Nullable f where
   null :: f a -> Bool

 instance Nullable (Maybe a) where
   null = isNothing

 pattern Null :: Nullable f => f a
 pattern Null = (null -> True)
 }}}

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


More information about the ghc-tickets mailing list