[GHC] #12471: Weirdness when using quosiquoter in pattern synonyms / GADT context

GHC ghc-devs at haskell.org
Sat Aug 6 19:00:46 UTC 2016


#12471: Weirdness when using quosiquoter in pattern synonyms / GADT context
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
                                     |  TemplateHaskell, PatternSynonyms,
                                     |  GADTs
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 Iceland_jack:

@@ -1,1 +1,1 @@
- Using [https://hackage.haskell.org/package/applicative-
+ ~~Using [https://hackage.haskell.org/package/applicative-
@@ -40,0 +40,1 @@
+ ~~

New description:

 ~~Using [https://hackage.haskell.org/package/applicative-
 quoters-0.1.0.8/docs/Control-Applicative-QQ-Idiom.html idiom brackets], is
 this a bug?

 {{{#!hs
 import Control.Applicative.QQ.Idiom

 data Exp a where
   I :: Int -> Exp Int

 pattern MkI :: Int ~ a => a -> Exp a
 pattern MkI a = I a

 c :: Exp a -> IO a
 c (MkI n) = pure n
 }}}

 This works. If I replace `pure n` by `[i| n |]` I get this error:

 {{{
 tKTa.hs:10:4-8: error: …
     • Couldn't match type ‘a’ with ‘Int’ arising from a pattern
       ‘a’ is a rigid type variable bound by
         the type signature for:
           c :: forall a. Exp a -> IO a
         at /tmp/tKTa.hs:9:6
     • In the pattern: MkI n
       In an equation for ‘c’: c (MkI n) = (pure n)
     • Relevant bindings include
         c :: Exp a -> IO a (bound at /tmp/tKTa.hs:10:1)
 Compilation failed.
 }}}

 This works without the pattern synonym

 {{{#!hs
 c :: Exp a -> IO a
 c (I n) = [i| n |]
 }}}
 ~~

--

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


More information about the ghc-tickets mailing list