Or just use runhaskell

Create a file Main.hs and write the following code

It's like the main from Java or C++. When you compile Haskell code, the main function runs.

It must be an IO type.

main is the "entry point of a Haskell program" *

do is a keyword in Haskell, like let or where .

Input is just as straight forward.

The symbol is pronounced "drawn from"

We have seen the <- symbol before

getLine gives back a String to use

putStrLn displays something to your monitor. That's a side effect!

If you see IO, think side effects.

I/O actions only exist within other I/O actions.

return

return is a function that "makes an I/O action out of a pure value" *

Prelude> :t return return :: Monad m => a -> m a

return "hello" :: IO String

It's pretty much the opposite of the <- syntax.

main = do input

return packs up a value into an IO box. <- extracts the value out of an IO box.

The return function is nothing like the one you've used in Java or C++.