[GHC] #13735: RankNTypes don't work with PatternSynonyms

GHC ghc-devs at haskell.org
Wed May 24 16:38:10 UTC 2017


#13735: RankNTypes don't work with PatternSynonyms
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  bug               |               Status:  closed
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:  invalid           |             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:                    |
-------------------------------------+-------------------------------------

Comment (by Iceland_jack):

 A coworker at work helped me reach this

 {{{#!hs
 newtype A = A (forall xx. xx -> xx)

 newtype Endo a = Endo { appEndo :: a -> a }
 newtype B = B (forall xx. Endo xx)

 pattern PatB :: (forall xx. xx -> xx) -> B
 pattern PatB f <- ((\(B f) -> A (appEndo f)) -> A f)
   where PatB f = B (Endo f)
 }}}

 which works, similarly with `PLambda`

 {{{#!hs
 data PLambda a = Lam { unLam :: a -> PLambda a } | ...

 newtype LAM = LAM (forall xx. xx -> PLambda xx)

 newtype Lam = L (forall a. PLambda a)

 get :: Lam -> LAM
 get (L f) = LAM (unLam f)

 pattern LLAM :: (forall a. a -> PLambda a) -> Lam
 pattern LLAM f <- (get -> LAM f)
   where LLAM f = L (Lam f)
 }}}

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


More information about the ghc-tickets mailing list