Three things that I can see:
-
You have the arguments that you pass to
scramble
inmain
the wrong way round. -
You haven’t defined
getContents
anywhere. -
You’re not using
getArgs
as you require.
As you guessed, you only need to get the first argument (as getArgs :: IO [String]
); using arg1:_ <- getArgs
will indeed get you the first argument (assuming there is at least one, otherwise there will be an error). However, you will have that arg1 :: String
, and you require an Int
, so you need a function of type String -> Int
.
This is my understanding based upon how you’ve defined scramble
(which seems to be something like a Vigenere cipher), which is completely different from how you defined your initial problem.