With this code:
main :: FilePath -> FilePath -> IO ()
main wrPath rdPath = do x <- readFile rdPath
writeFile wrPath x
As GolezTrol said, all programs need to know which symbol to start executing when the function is invoked. Many scripting languages don't require (or just don't need) a main
routine as they can have statements placed on the top level. This is not the case for Haskell, C and many others - these languages need a starting location and by convention that is the main
function (as per the Haskell spec - see Cat's answer).
Notice Haskell's main
does not accept any parameters that correspond to the program arguments - these are obtained via System.Environment.getArgs
.