[GHC] #12366: Use TypeOperators for pattern synonyms?

#12366: Use TypeOperators for pattern synonyms? -------------------------------------+------------------------------------- Reporter: dubiousjim | Owner: Type: feature | Status: new request | Priority: low | Milestone: Component: Compiler | Version: 8.0.1 (Parser) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- With the language setting `-XTypeOperators`, I can use ''varsym'' expressions, like `<|`, as type constructors. I would expect that we would then also be able to use them as pattern synonyms; but we can't. This is a request for that to become possible. {{{#!hs {-# LANGUAGE TypeOperators, PatternSynonyms #-} module Main where pattern (<|) x xs = Just (x, xs) main = case Just (1, [2,3]) of { Nothing -> putStrLn "Nothing"; y <| ys -> print y } }}} gives a parse error. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12366 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12366: Use TypeOperators for pattern synonyms? -------------------------------------+------------------------------------- Reporter: dubiousjim | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: 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): Unfortunately, I don't think this is possible. The type-level namespace and the term-level namespace are organized differently: `|>` in a type is indeed like a capitalized word, but `|>` in a term is like a lowercase word. The problem is, as I understand it, that the parser needs to be able to know where the constructors/pattern synonyms are in a pattern. Is `C (|>)` binding the variable `|>` or are we matching against a nullary pattern synonym `|>`? It's impossible to tell. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12366#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12366: Use TypeOperators for pattern synonyms? -------------------------------------+------------------------------------- Reporter: dubiousjim | Owner: Type: feature request | Status: closed Priority: low | Milestone: Component: Compiler | Version: 8.0.1 (Parser) | Keywords: Resolution: invalid | 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: | -------------------------------------+------------------------------------- Changes (by mpickering): * keywords: => PatternSynonyms * status: new => closed * resolution: => invalid Comment: Pattern synonym names live in the data constructor name space whilst the type operators extension only affects type constructors. Pattern synonym definitions define no type construction so there shouldn't be any interaction between the two features. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12366#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12366: Use TypeOperators for pattern synonyms? -------------------------------------+------------------------------------- Reporter: dubiousjim | Owner: Type: feature request | Status: closed Priority: low | Milestone: Component: Compiler | Version: 8.0.1 (Parser) | Keywords: Resolution: invalid | 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 dubiousjim): Ok, thanks for the prompt and clear explanation. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12366#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC