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

GHC ghc-devs at haskell.org
Wed May 24 21:35:52 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 dfeuer):

 Your `get` is partial, so matching on `LLAM` will throw an exception
 (instead of failing) when it doesn't match. It's possible to accomplish
 your purpose thus:

 {{{#!hs
 data Yeah = Yeah (forall a. a -> PLambda a) | Nah

 getYeah :: Lam -> Yeah
 getYeah l@(L (Lam _)) = Yeah (case l of L (Lam f) -> f; _ -> error
 "impossible")
 getYeah _ = Nah

 pattern LLam :: (forall a. a -> PLambda a) -> Lam
 pattern LLam x <- (getYeah -> Yeah x)
 }}}

 It's pretty ugly, though. You have to first pattern match to determine
 that the constructor is `Lam`, then pattern match on the same value again
 under the `Yeah` constructor to capture the polymorphism. If there's a way
 to avoid that, I don't see it.

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


More information about the ghc-tickets mailing list