[GHC] #10708: Rejection of constant functions defined using conditional pattern matching
GHC
ghc-devs at haskell.org
Thu Jul 30 11:50:48 UTC 2015
#10708: Rejection of constant functions defined using conditional pattern matching
-------------------------------------+-------------------------------------
Reporter: HubertGaravel | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.1
Resolution: invalid | Keywords:
Operating System: Linux | Architecture: x86
Type of failure: GHC rejects | Test Case:
valid program |
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by HubertGaravel):
Thanks for the insight. If I try to reformulate, the definition of d3 is
allowed by the syntax but forbidden by the static semantics.
Perhaps the static semantics rule is too rigid and could be relaxed to
make Haskell more regular. The example below shows that regularity is
broken for arity 0 (empty pattern list). But I can live with this
bizarre exception and will modify my Haskell generator to handle this
corner case.
Thanks again!
Hubert
{{{#!hs
-- valid for arity 2
f2 x y | x == 0 = x
f2 x y | x /= 0 = x + 1
-- valid for arity 1
f1 x | x == 0 = x
f1 x | x /= 0 = x + 1
-- invalid for arity 0
f0 | 0 == 0 = 0
f0 | 0 /= 0 = 1
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10708#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list