Reading — step 1 of 5
Learn
~1 min readGetting 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.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…