Skip to content
Lesson 1 of 15

Step 1 of 5 · Reading · ~1 min

Learn

Getting Started

Haskell is pure functional — functions don't have side effects (mostly). Anything that touches the outside world goes through IO.

main :: IO ()
main = do
    putStrLn "Hello, World!"
    putStrLn "Ship That Code"

The entry point is main of type IO () — an IO action that returns unit. The do block sequences IO actions.

putStrLn prints a string with a newline. putStr skips the newline. The :: is a type annotation — name :: Type.

Type signatures are usually optional (Haskell infers them) but it's idiomatic to annotate top-level bindings for documentation and to catch type errors at the right place.

Up nextVariables and TypesGetting Started

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…