If I run the following file:
ll [] = 0
ll (x:xs) = 1 + ll xs
main = putStrLn (show (ll [2,2,2]))
using runghc, it works and prints 3.
In ghci, otoh, I get:
ghci> let ll [] = 0
ghci> let ll (x:xs) = 1 + ll xs
ghci> ll [3,4,43,9]
*** Exception: <interactive>:23:5-25: Non-exhaustive patterns in function ll
What's the reason the above code fails to work in ghci? What changes are needed to make it work?