I am learning Haskell and wanted to write a simple program which just repeats each letter in a string twice.
I came up with this:
repl :: String -> String
repl " " = " "
repl (x:xs) = x:x:repl xs
When compiling, I didnt get any warning but a run-time error occurred when I did repl "abcd":
"abcd*** Exception: repl.hs:(2,1)-(3,23): Non-exhaustive patterns in function repl
Why did the compiler never report this and why is it ignored in Haskell when there are many languages like OCaml which clearly report this at compile time?
ghc -fwarn-incomplete-patternsseems appropriate... - recursion.ninja