From the haskell.org website: every expression has a type. So what is the type of
main = putStrLn "Hello, World!"
I would like to know not what the type of main
is, but what the type of the whole line is. Also, is it possible to get this type somehow in ghci? I tried
:t (main = putStrLn "Hello, World!")
but this does not work.
main = putStrLn "Hello, World!"
is not an expression, and thus does not have a type. It's a definition, which assigns a value of type IO ()
(resulting from the evaluation of putStrLn :: String -> IO ()
) to the name main
.
Following the definition, you can find the type of main
:
> :t main
main :: IO ()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With