[GHC] #8927: Multiple case match at once

#8927: Multiple case match at once -------------------------------------------+------------------------------- Reporter: vxanica | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Parser) | Version: 7.6.3 Keywords: case, multiple | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Easy (less than 1 hour) | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: -------------------------------------------+------------------------------- In F# we can do {{{ #!div style="font-size: 120%" {{{#!haskell match x with | 1 | 2 | 3 -> "123" | 4 | 5 | 6 -> "456" }}} }}} It will be nice if we have an extension which allows us to do {{{ #!div style="font-size: 120%" {{{#!haskell case x of 1 | 2 | 3 -> "123" 4 | 5 | 6 -> "456" }}} }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8927 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8927: Multiple case match at once -------------------------------------+------------------------------------- Reporter: vxanica | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.1-rc2 (Parser) | Keywords: case, multiple Resolution: | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Changes (by vxanica): * cc: vxanicauk@… (added) * version: 7.6.3 => 7.8.1-rc2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8927#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8927: Multiple case match at once -------------------------------------+------------------------------------- Reporter: vxanica | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.1-rc2 (Parser) | Keywords: case, multiple Resolution: | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by Fuuzetsu): What happens in the case like {{{ #!div style="font-size: 120%" {{{#!haskell case x of Just y | Nothing -> y }}} }}} While I think it'd be nice to have, the utility seems limited to constructors without arguments. Would this work? {{{ #!div style="font-size: 120%" {{{#!haskell data Foo = A Int | B Int | C String case x of A y | B y = "AB" ++ show y C y -> y }}} }}} and would this work? {{{ #!div style="font-size: 120%" {{{#!haskell data Foo = A Int | B () | C Double case x of A y | B y | C y = show y }}} }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8927#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8927: Multiple case match at once -------------------------------------+------------------------------------- Reporter: vxanica | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.1-rc2 (Parser) | Keywords: case, multiple Resolution: | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by hvr): Replying to [ticket:8927 vxanica]:
{{{#!haskell case x of 1 | 2 | 3 -> "123" 4 | 5 | 6 -> "456" }}}
btw, this concrete syntax would collide with Haskell2010's [http://www.haskell.org/haskellwiki/Pattern_guard Pattern Guards] -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8927#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8927: Multiple case match at once -------------------------------------+------------------------------------- Reporter: vxanica | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.1-rc2 (Parser) | Keywords: case, multiple Resolution: | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by schyler): Why not swap out | with , ? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8927#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8927: Multiple case match at once --------------------------------------+------------------------------------ Reporter: vxanica | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Parser) | Version: 7.8.1-rc2 Resolution: | Keywords: case, multiple Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: --------------------------------------+------------------------------------ Changes (by nomeata): * difficulty: Easy (less than 1 hour) => Unknown -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8927#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8927: Multiple case match at once -------------------------------------+------------------------------------- Reporter: vxanica | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.1-rc2 (Parser) | Keywords: case, Resolution: | multiple Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #3919 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by gkaracha): * cc: gkaracha (added) * related: => #3919 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8927#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8927: Multiple case match at once -------------------------------------+------------------------------------- Reporter: vxanica | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.1-rc2 (Parser) | Keywords: case, Resolution: | multiple Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #3919 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): I like the idea of disambiguating or-patterns and guards with parentheses, since I expect to be able to use or-patterns compositionally (nested within a larger pattern) anyways. So for hvr's last example {{{#!hs case x of (False | True) -> "123" }}} Don't know if this would cause major problems in the parser. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8927#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC