
Hi, Am Mittwoch, den 29.11.2017, 11:04 +0100 schrieb Henning Thielemann:
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"
You can write case id (0::Int) of 0 -> putStrLn "A" 1 -> putStrLn "B" _ -> putStrLn "C" instead.
I mean, this one does not provoke any warnings:
if True then putStrLn "X" else putStrLn "Y"
but is limited to two branches.
It looks like a but that it warns for Int, but not for Bool… freel free to report that (https://ghc.haskell.org/trac/ghc/wiki/ReportABug). Joachim -- Joachim “nomeata” Breitner mail@joachim-breitner.de https://www.joachim-breitner.de/