
I thought that "redundant" means that the first two cases overlap with '_'. But if I replace '_' by '2' I get not only the non-exhaustive patterns warning but an additional redundancy warning on pattern '2'.
I think it's a bug of the PM check instead: it doesn't correctly detect redundant Int alternatives ("1" and "_" in your example). Could you report it as a bug? Note that it works as expected with Integer: "case 0 :: Integer of" reports "1 ->..." and "_ -> ..." as redundant. A solution to avoid the warning is: let choosePut = 0 :: Int case choosePut of 0 -> putStrLn "A" 1 -> putStrLn "B" _ -> putStrLn "C" -Sylvain On 29/11/2017 11:04, Henning Thielemann wrote:
Occasionally I have multiple implementations of the same task and want to choose one quickly but statically. I do not want to out-comment unused branches because they shall still be type checked. So far I used this scheme:
case 0::Int of 0 -> putStrLn "A" 1 -> putStrLn "B" _ -> putStrLn "C"
With ghc-8.0.2 and ghc-8.2.2 I get these warnings:
RedundantCase.hs:4:7: warning: [-Woverlapping-patterns] Pattern match is redundant In a case alternative: 0 -> ...
RedundantCase.hs:5:7: warning: [-Woverlapping-patterns] Pattern match is redundant In a case alternative: 1 -> ...
I thought that "redundant" means that the first two cases overlap with '_'. But if I replace '_' by '2' I get not only the non-exhaustive patterns warning but an additional redundancy warning on pattern '2'.
Is there a nice way to tell GHC that the unused branches are intended, without generally disabling overlapping patterns warning?
I mean, this one does not provoke any warnings:
if True then putStrLn "X" else putStrLn "Y"
but is limited to two branches. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.