Lesson 02 of 55
8 mins readPython Syntax, Comments & Program Layout
In Plain English
Haskell uses significant indentation (the layout rule) to group code blocks. Single-line comments start with -- and multi-line comments use {- ... -}.
Deep Dive: How It Works
The Layout Rule: Code indented further than the beginning of a statement belongs to that statement. Semicolons and curly braces are optional.
Single-Line Comments: Use -- for comments to the end of the line.
Multi-Line Comments: Use {- and -} for block comments, which can be nested arbitrarily.
Core Rules to Remember

Whitespace & Indentation: Indentation defines syntactic scope without requiring closing braces.

Nestable Comments: Block comments {- ... -} can be nested inside each other safely.
Live Interactive Example
Hit Run Code to see it liveComments and Multi-Line Block
Python 3.12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Output Console
Click "Run Code" to view the rendered output.
How it works: ++ concatenates strings. Indentation inside do groups sequential IO actions.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Format Output String
Complete `main` to output `"ZenCompiler: Pure Functional Engine"`.
1
2
3
4
Sandbox Output
Click "Run & Check" to test your solution.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.