[GHC] #11351: Scoped type variables in pattern synonyms

#11351: Scoped type variables in pattern synonyms -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 8.1 (Type checker) | Keywords: | Operating System: Linux Architecture: | Type of failure: GHC rejects Unknown/Multiple | valid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Unsure of pattern synonym scoping rules. I want to be able to refer to a type in the signature (assuming `symbol` from #11349): {{{#!hs symbol :: forall s. KnownSymbol s => String symbol = symbolVal @s Proxy -- Not in scope: type variable ‘s’ -- Not in scope: type variable ‘s’ pattern Symbol :: forall s. KnownSymbol s => String pattern Symbol <- ((== symbol @s) -> True) where Symbol = symbol @s }}} Without `TypeApplications`: {{{#!hs -- • Could not deduce (KnownSymbol n0) -- arising from a use of ‘symbolVal’ -- from the context: KnownSymbol s -- bound by the type signature for pattern synonym ‘Symbol’: -- String pattern Symbol :: forall s. KnownSymbol s => String pattern Symbol <- ((== symbolVal (Proxy :: Proxy s)) -> True) }}} but it (GHCi, version 8.1.20160102) says the type variable `s` is not in scope. The desired outcome would be something like (this touches on ticket #11350): {{{#!hs
Symbol @"blessed duck" "blessed duck"
isDuck :: String -> Bool isDuck (Symbol @"duck") = True isDuck _ = False }}} With a nudge and a wink to #9671. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11351 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11351: Scoped type variables in pattern synonyms -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.1 checker) | Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by Iceland_jack: Old description:
Unsure of pattern synonym scoping rules. I want to be able to refer to a type in the signature (assuming `symbol` from #11349):
{{{#!hs symbol :: forall s. KnownSymbol s => String symbol = symbolVal @s Proxy
-- Not in scope: type variable ‘s’ -- Not in scope: type variable ‘s’ pattern Symbol :: forall s. KnownSymbol s => String pattern Symbol <- ((== symbol @s) -> True) where Symbol = symbol @s }}}
Without `TypeApplications`:
{{{#!hs -- • Could not deduce (KnownSymbol n0) -- arising from a use of ‘symbolVal’ -- from the context: KnownSymbol s -- bound by the type signature for pattern synonym ‘Symbol’: -- String pattern Symbol :: forall s. KnownSymbol s => String pattern Symbol <- ((== symbolVal (Proxy :: Proxy s)) -> True) }}}
but it (GHCi, version 8.1.20160102) says the type variable `s` is not in scope. The desired outcome would be something like (this touches on ticket #11350):
{{{#!hs
Symbol @"blessed duck" "blessed duck"
isDuck :: String -> Bool isDuck (Symbol @"duck") = True isDuck _ = False }}}
With a nudge and a wink to #9671.
New description: Unsure of pattern synonym scoping rules. I want to be able to refer to a type in the signature (assuming `symbol` from #11349): {{{#!hs symbol :: forall s. KnownSymbol s => String symbol = symbolVal @s Proxy -- Not in scope: type variable ‘s’ -- Not in scope: type variable ‘s’ pattern Symbol :: forall s. KnownSymbol s => String pattern Symbol <- ((== symbol @s) -> True) where Symbol = symbol @s }}} Without `TypeApplications`: {{{#!hs -- • Could not deduce (KnownSymbol n0) -- arising from a use of ‘symbolVal’ -- from the context: KnownSymbol s -- bound by the type signature for pattern synonym ‘Symbol’: -- String pattern Symbol :: forall s. KnownSymbol s => String pattern Symbol <- ((== symbolVal (Proxy :: Proxy s)) -> True) }}} but it (GHCi, version 8.1.20160102) says the type variable `s` is not in scope. Is this intentional? -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11351#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11351: Scoped type variables in pattern synonyms -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.1 checker) | Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): You are right: scoped type variables from the pattern signature should scope, and they simply don't right now. That's a bug; or at least a serious inconsistency. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11351#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11351: Scoped type variables in pattern synonyms -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1-rc1 checker) | Keywords: Resolution: | PatternSynonyms Operating System: Linux | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * keywords: => PatternSynonyms * cc: mpickering (added) * version: 8.1 => 8.0.1-rc1 * type: feature request => bug -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11351#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11351: Scoped type variables in pattern synonyms
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.0.1-rc1
checker) | Keywords:
Resolution: | PatternSynonyms
Operating System: Linux | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#11351: Scoped type variables in pattern synonyms -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: merge Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1-rc1 checker) | Keywords: Resolution: | PatternSynonyms Operating System: Linux | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => merge Comment: I think it'd be safe to merge this. Still missing is a refactoring of the pattern-synonym documentation. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11351#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11351: Scoped type variables in pattern synonyms -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 8.0.1-rc1 checker) | Keywords: Resolution: fixed | PatternSynonyms Operating System: Linux | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed * milestone: => 8.0.1 Comment: This has been merged to `ghc-8.0` as 8c10ee3cacdd4f88561751e96831435397aef4e9. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11351#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC