I'm just starting to look into Haskell. I've written a naive Fibonacci implementation, and I've also written a more advanced one that uses tail-call recursion for efficiency.
module Fibonacci where import System.Environment fibonacci :: Integer -> Integer fibonacci 0 = 0 fibonacci 1 = 1 fibonacci n | n < 0 = error "Cannot find a negative fibonacci number" | otherwise = fibonacci (n - 1) + fibonacci (n - 2) fibonacci' :: Integer -> Integer fibonacci' n | n < 0 = error "Cannot find a negative fibonacci number" | otherwise = fibHelper n 0 1 where fibHelper :: Integer -> Integer -> Integer -> Integer fibHelper n a b | n == 0 = a | otherwise = fibHelper (n - 1) b (a + b) firstNumberFrom :: [String] -> Integer firstNumberFrom  = 10 firstNumberFrom args = read $ args !! 0 main = do args <- getArgs let num = firstNumberFrom args in putStrLn $ show (fibonacci' num)
I'd appreciate any reviews on correctness and idiomatic usage.