[GHC] #7676: Conflicting definitions error for simple variable with guards

#7676: Conflicting definitions error for simple variable with guards --------------------------------------+------------------------------------- Reporter: Mathnerd314 | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.7 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: GHC rejects valid program | Blockedby: Blocking: | Related: --------------------------------------+------------------------------------- The following program: {{{ a | True = 1 a | False = 2 }}} produces an error (on 7.4.1 and 7.7.2012117): {{{ Conflicting definitions for 'a' }}} The following two examples produce no error: {{{ b | True = 1 | False = 2 c _ | True = 1 c _ | False = 2 }}} I would expect `a`, `b`. and `c ()` to have identical behaviour. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7676 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7676: Conflicting definitions error for simple variable with guards ----------------------------------------+----------------------------------- Reporter: Mathnerd314 | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: wontfix | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: GHC rejects valid program | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Changes (by igloo): * status: new => closed * difficulty: => Unknown * resolution: => wontfix Comment: Thanks for the report. However, this matches the behaviour specified by the report; see http://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-830004.4... for details. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7676#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7676: Conflicting definitions error for simple variable with guards ----------------------------------------+----------------------------------- Reporter: Mathnerd314 | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: wontfix | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: GHC rejects valid program | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Comment(by guest): Note that this is not specific to guards. {{{ f = 0 -- error f = 0 g _ = 0 -- correct g _ = 0 }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7676#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7676: Unify patterns and function bindings ----------------------------------------+----------------------------------- Reporter: Mathnerd314 | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: GHC rejects valid program | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Changes (by Mathnerd314): * status: closed => new * type: bug => feature request * resolution: wontfix => Comment: Ah, so I am really filing a feature request! I propose an extension which changes the grammar to be as follows: {{{ decl → funlhs rhs funlhs → pat { apat } | pat varop pat | ( funlhs ) { apat } apat → funlhs | var [ @ apat] | ... }}} I think this introduces a small amount of ambiguity in the grammar (funlhs → pat → lpat → apat → funlhs), but it should be easy to transform the grammar so as to avoid it. Note that your definition for g, although not rejected outright by GHC, does produce a warning that "Pattern matches are overlapped." I think such a warning would suffice for f as well. There is nothing in the report specifying that multiple pattern bindings MUST give an error; instead, it is mute on the subject. It does not even specify the semantics of single pattern bindings very clearly, as the (implemented but still unaccepted?) proposal http://hackage.haskell.org/trac/haskell- prime/wiki/SpecifyPatternBindingSemantics shows. This grammar allows convenient definitions such as the following (adapted from the numbers package) {{{ (x < y, x > y) = (<0) &&& (>0) $ s' (digitsToBits digits) where (CR s') = x-y }}} desugared as follows: {{{ z x y = (<0) &&& (>0) $ s' (digitsToBits digits) where (CR s') = x-y x > y = case (z x y) of { (x < y, x > y) -> (x > y) } x < y = case (z x y) of { (x < y, x > y) -> (x < y) } }}} The case expression should perhaps be desugared a bit more so the semantics are clear: {{{ case (z x y) of { (a,b) -> let { (x < y) = a; (x > y) = b } in ... } }}} If you think this is too mind-bending to be useful, I suppose the syntax could be restricted a bit; but I find the generality to be rather pretty. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7676#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7676: Unify patterns and function bindings ----------------------------------------+----------------------------------- Reporter: Mathnerd314 | Owner: Type: feature request | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: GHC rejects valid program | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Changes (by igloo): * milestone: => 7.8.1 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7676#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC