0

I am learning Haskell and I'm not very good at it yet... Some of the tutorials I've read (Haskell's String IO and Learn You a Haskell) have explained a lot of things about IO, but I still could not write my desired function:

TutorialCopy inputName outputName = do
                                    contents <- Str.readFile inputName  -- Opens the target File.
                                    writeFile outputName contents       -- Creates the destination File.

The Idea here was to read a file based on the Input File's location ('inputName') and have it's contents transferred to the Output File ('outputName'). I have also tried the function type:

TutorialCopy :: FilePath -> FilePath -> IO ()

Or even:

TutorialCopy :: String -> String -> IO ()

With no success whatsoever, as GHCi returns signature errors when I declare the signature or a data constructor error when I don't.

I appreciate all the help, thank you!

4

1 回答 1

3

Haskell has some enforced named conventions. Function names must start with a lowercase letter, data types and constructors start with an uppercase letter. Change the name of your function to tutorialCopy, that should fix it.

于 2013-10-09T13:01:23.863 回答