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

#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 Keywords: | Operating System: Unknown/Multiple TemplateHaskell, PatternSynonyms, | GADTs | Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- 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 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

:i MkI
#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: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): It also works if I omit the type signature of `MkI` resulting in the inferred type {{{ pattern MkI :: () => t GHC.Prim.~# Int => Int -> Exp t }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12471#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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

#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

#12471: Weirdness when using fromIntegral in quosiquoter -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | TemplateHaskell Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Iceland_jack): * keywords: TemplateHaskell, PatternSynonyms, GADTs => TemplateHaskell * cc: mpickering (removed) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12471#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12471: Weirdness when using fromIntegral in quosiquoter -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | TemplateHaskell 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 goldfire): What makes you think this is a GHC bug and not a bug in the implementation of `i`? Alternatively, what's the behavior when you paste in the output of `-ddump-splices`? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12471#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12471: Weirdness when using fromIntegral in quosiquoter -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: infoneeded Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | TemplateHaskell Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => infoneeded -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12471#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC