
#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- @@ -8,8 +8,2 @@ - 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 + c :: Int -> IO Integer + c n = [i| fromIntegral n::Integer |] @@ -18,1 +12,1 @@ - This works. If I replace `pure n` by `[i| n |]` I get this error: + This works. Removing the type annotation: @@ -20,0 +14,6 @@ + {{{#!hs + import Control.Applicative.QQ.Idiom + + c :: Int -> IO Integer + c n = [i| fromIntegral n |] + }}} @@ -21,10 +21,5 @@ - 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) + t0sj.hs:4:10-27: error: … + • Couldn't match expected type ‘IO Integer’ with actual type ‘Int’ + • In the second argument of ‘(<*>)’, namely ‘n’ + In the expression: (((pure fromIntegral) <*> n)) + In an equation for ‘c’: c n = (((pure fromIntegral) <*> n)) @@ -33,8 +28,0 @@ - - This works without the pattern synonym - - {{{#!hs - c :: Exp a -> IO a - c (I n) = [i| n |] - }}} - ~~ 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 c :: Int -> IO Integer c n = [i| fromIntegral n::Integer |] }}} This works. Removing the type annotation: {{{#!hs import Control.Applicative.QQ.Idiom c :: Int -> IO Integer c n = [i| fromIntegral n |] }}} {{{ t0sj.hs:4:10-27: error: … • Couldn't match expected type ‘IO Integer’ with actual type ‘Int’ • In the second argument of ‘(<*>)’, namely ‘n’ In the expression: (((pure fromIntegral) <*> n)) In an equation for ‘c’: c n = (((pure fromIntegral) <*> n)) Compilation failed. }}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12471#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler