[GHC] #11390: GHC does not warn about redundant patterns
GHC
ghc-devs at haskell.org
Mon Jan 11 17:07:01 UTC 2016
#11390: GHC does not warn about redundant patterns
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.1
Resolution: | Keywords: warnings,
| PatternMatchWarnings
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 gkaracha):
Actually nothing is redundant in the above examples. As we discuss in the
paper (section about
laziness), `(sillyId undefined)` will give you the right hand-side so the
clause:
{{{#!hs
sillyId x = x
}}}
is not redundant at all. Of course, this is not the case for:
{{{#!hs
sillyId2 :: F1 Char -> F1 Char
sillyId2 (!x) = x
}}}
because it is strict in the argument, so no WHNF can have the type `F1
Char`. But even in this
case, the clause is not actually redundant, it just has an inaccessible
RHS (remember this is
not Agda). Pattern matching is not just used for discrimination in Haskell
but also for evaluation,
which I see as a side effect. Hence, the clause may have an inaccessible
RHS, but by removing it
the expression is not evaluated and you change the semantics of
`sillyId2`.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11390#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list