HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Modulevortex-elab-0.2.2GHC2024

Vortex.Elab.Block

Reading a flat vortex file as a do block. A .vx file (or a multi-line REPL block) is statements at the left margin, one per column-zero line, with indented lines continuing the statement above: no leading do, no explicit separators. blockDo is the one reading every host applies before elaboration, so the file format is the same everywhere.

  • 1 value
valueblockDo :: String -> String
#

Wrap a flat block into a do that GHC reads as the file itself, so an error names the file's own line and column. A single statement (or a pure expression like 1 + 1) is left exactly as written, so one-liners and non-monadic blocks still elaborate as bare expressions.

The source is left as written under one line that opens the do: an empty statement at column one, which puts the block's statements at the left margin, and a LINE pragma that numbers the source from its own first line, under the name <hint> that vortex-elab gives every source. GHC then reads the statements by its layout rule, as it reads a do block in a file: a column-zero line starts a statement, an indented one continues it, so the body of a let, where, case or inner do is laid out as written, and comment and blank lines are space. Nothing in the block moves against the rest of it, so a host that indents every line, or puts text of its own before the block outside any layout block, reads it the same. Inside one, such as a let of the host's around it, the empty statement at column one closes the host's block instead.