[GHC] #11461: Allow pattern synonyms to be bundled with type classes?
GHC
ghc-devs at haskell.org
Wed Jan 20 20:09:43 UTC 2016
#11461: Allow pattern synonyms to be bundled with type classes?
-------------------------------------+-------------------------------------
Reporter: mpickering | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.3
Resolution: | Keywords:
| PatternSynonyms
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Description changed by hvr:
@@ -11,1 +11,1 @@
- {{{
+ {{{#!hs
New description:
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.
{{{#!hs
{-# 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#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list