How to open .LHS files on Windows

To open .LHS files on Windows, open the .lhs file in a plain-text/code editor (for example, right-click → Open with → choose a text editor).

Step-by-step instructions

  1. Open the .lhs file in a plain-text/code editor (for example, right-click → Open with → choose a text editor).
  2. If you need to compile it, install a Haskell toolchain that includes GHC, then compile the file as you would other Haskell sources (GHC treats .lhs as literate input).
  3. If it displays with wrong formatting, ensure the editor is using plain-text mode and not a word-processor format.

Common issues

The file opens, but the code parts look wrong

Literate Haskell relies on specific conventions to distinguish documentation from code; viewing it in a word processor or with incorrect text settings can make the code blocks hard to identify.

  1. Open the file in a plain-text/code editor rather than a word processor.
  2. If you are compiling, use GHC (it applies the literate pre-processor for .lhs) and confirm the file follows literate conventions described in the Haskell report.

Compilation fails because it is treated like normal .hs source

If the toolchain is not using a literate-aware compilation path, the documentation lines can be interpreted as code and cause errors.

  1. Compile with GHC using the .lhs file directly so the literate pre-processor stage is applied.
  2. Confirm you did not rename a .hs file to .lhs (or vice versa) without adjusting the file’s content to match literate conventions.

My system does not recognize .lhs / opens it with the wrong app

File-type associations vary by platform; some systems may not have a built-in association for Literate Haskell.

  1. Use “Open with…” and choose a text editor, then set it as the default for .lhs if desired.
  2. On Linux desktops, recognition can depend on the shared MIME database installed on the system.

Security note

.lhs files are plain text, but they can contain Haskell code that may run arbitrary actions when compiled/executed; treat untrusted .lhs files like any other source code you might run.

Back to .LHS extension page