I try to use CmdArgs to extract an integer from the command line arguments:
./prg –byte=512
The below code does not compile and the compiler says Couldn't match expected type `Int' with actual type `Strlen -> Int'. Now, I thought that I had deemed byte to be an integer? Isn’t it?
{-# LANGUAGE DeriveDataTypeable #-}
import System.Console.CmdArgs
data Strlen = Strlen {byte :: Int} deriving (Data, Typeable)
strlen = cmdArgsMode $ Strlen {byte = def}
main = do
n <- cmdArgsRun strlen
let datastring = take byte $ randomRs ('a','Z') (mkStdGen 3)
To select the
bytefield fromnyou need to saybyte n. So