For example, take the code written by don Stewart in response to a question:
import Control.Monad
import qualified Data.HashTable as H
import System.Environment
main = do
[size] <- fmap (fmap read) getArgs
m <- H.new (==) H.hashInt
forM_ [1..size] $ \n -> H.insert m n n
v <- H.lookup m 100
print v
Upload it to GHCi.
:t getArgs ---> getArgs :: IO [String]
:t main ---> main :: IO ()
Why does a signature of type main not reflect the fact that it getArgs :: IO [String]is being called?
When you run the binary, you can give an argument.
<prog> 145returns Just 100
But in GHCi you cannot: main 145gives an error. How to run this program in GHCi and give an argument.
source
share