Zeh
Zeh

Reputation: 188

Opening Files in Haskell using String parameters

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!

Upvotes: 0

Views: 255

Answers (1)

fjarri
fjarri

Reputation: 9726

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.

Upvotes: 3

Related Questions