RANA
Client-Side Haskell & Monadic Code Beautifier

Online Haskell Code Formatter & Beautifier

Clean, structure, and auto-indent Haskell modules, monadic do-blocks, where/let clauses, and algebraic data types instantly. Enforce clean 2-space or 4-space layout alignment with zero server transmission.

0Max Nesting
0Scope Clauses
0Total Lines
0Characters
Sample:|
Live Client-Side Alignment
Open in Haskell Validator↗

Understanding the Haskell Layout Rule & Indentation

Haskell uses the famous off-side rule (syntactic layout), meaning that whitespace and indentation define code blocks without needing curly braces or semicolons. Keywords like where, let, do, case...of, and class establish an indentation column for all subsequent statements. Misaligned indentation is one of the most common compilation blockers in GHC, making automated layout indentation essential.

The Standard 2-Space Rule

Modern formatters like Ormolu and Fourmolu standardize on 2 spaces per indentation level. Hard tabs (\t) are strictly discouraged in GHC by default because visual tab widths vary across editors.

Monadic do Notation

Statements inside a do block must align vertically to the same column. Any statement indented further is parsed as an expression continuation of the previous line.

Haskell Style Guidelines: Standard Conventions vs. Messy Layouts

ConstructUnformatted / MisalignedBeautified Haskell StandardFormatting Rule
Monadic Do Blockmain = do putStrLn "Hello" name <- getLine putStrLn namemain = do putStrLn "Hello" name <- getLine putStrLn name2-space indent for all statements inside the do context.
Data Declarationdata Tree a = Leaf a | Node (Tree a) (Tree a)data Tree a = Leaf a | Node (Tree a) (Tree a)Aligning constructors with leading pipes enhances readability.
Where Clausecalc x = x * factor where factor = 42calc x = x * factor where factor = 42Indenting where prevents lexical collisions with top-level declarations.

Frequently Asked Questions

What indentation style does this Haskell formatter follow?

By default, it follows modern Haskell community conventions (similar to Ormolu and Fourmolu), utilizing 2 spaces or 4 spaces per nesting level without hard tabs.

How does it handle Haskell's off-side layout rule?

The engine identifies layout-triggering keywords such as 'do', 'where', 'let', 'of', and 'mdo', calculating consistent column indentations so that lexical scope is clearly preserved.

Is my proprietary Haskell source code sent to a remote server?

No. All formatting logic runs entirely inside your browser memory using JavaScript lexical parsing. Zero code or telemetry is transmitted across the network.