.LHS file extension

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).

To open a .lhs file, use a plain-text editor (for reading/editing) or a Haskell toolchain (for compiling/running). On desktop OSes, common code editors work; on mobile, viewing is typically possible but compiling is usually not.

Last updated: June 11, 2026 · Reviewed by Julian Stricker

What “reviewed” means on this page
  • Format fit: whether the “what is this file?” description matches common real-world use of the extension, including category, typical MIME types, and aliases.
  • Opening paths: whether Windows / macOS / Linux steps read plausibly for current OS dialogs and default apps; we remove fantasy menus and unsafe shortcuts.
  • Security framing: whether risk notes match the extension class (for example executables vs plain data) and whether affiliate wording does not contradict the security section.
  • Sources and further reading: whether external links point to vendors, standards bodies, or other primary references where possible; we avoid inventing details we cannot ground.
  • Limits: this is clarity and safety-messaging QA, not a guarantee that every statement is exhaustive or that every binary you download is harmless.

Full methodology in the Imprint The Imprint also states where AI is used and what that does—and does not—replace.

Open on your device

Choose your operating system for a dedicated step-by-step opening guide.

How to open .LHS files

Use these platform-specific instructions to open .LHS files safely.

Windows

  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.
Full Windows guide

Mac

  1. Open the .lhs file with a plain-text/code editor (Control-click → Open With → choose a text editor).
  2. To build/run it, use a Haskell toolchain that includes GHC; GHC supports .lhs via its literate pre-processor stage.
  3. If the file looks like a “document” but is unreadable, verify it is plain text (not a mislabeled binary file).
Full Mac guide

Linux

  1. Open the .lhs file in a text editor or IDE from your file manager (Open With → a text editor).
  2. To compile, use GHC; it accepts .lhs as input and applies the literate pre-processor automatically.
  3. If your desktop environment does not recognize the type, you can still open it as plain text.
Full Linux guide

iOS

  1. Use the Files app to preview it as text; if it does not render well, share it to a text-editor app or transfer it to a desktop for proper editing/compilation (compiling with GHC is typically not available on iOS).
Full iOS guide

Android

  1. Open it with a text-editor app as plain text; for compiling/running with GHC, transfer it to a desktop or Linux environment (GHC toolchains are typically used on desktop/server platforms).
Full Android guide

Security notes

  • .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.
  • Be cautious with build scripts or toolchain commands you use alongside a .lhs file; the risk typically comes from executing code or build steps, not from viewing the text.
  • If a purported .lhs file cannot be opened as text or looks like binary data, treat it as suspicious or mislabeled and avoid executing anything associated with it.

If you did not expect this file

This extension is usually plain data, text, or structured content—not a program by itself. The practical risk is social engineering (a scam attachment or misleading filename). For trusted senders you rarely need heavy-handed antivirus wording; use these tools when you want an extra check on unexpected downloads.

We may earn a commission when you use affiliate links. This supports our free file extension guides.

Can't open this file?

These are the most common causes and fixes when .LHS files fail to open.

Common reasons

  • The file opens, but the code parts look wrong
  • Compilation fails because it is treated like normal .hs source
  • My system does not recognize .lhs / opens it with the wrong app

Fix steps

  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.

What is a .LHS file?

.lhs is the conventional extension for Literate Haskell, a style of Haskell source where documentation and code are interleaved. It is still plain text, but compilers handle it via a “literate pre-processor” step before normal compilation. The Haskell 98 report and GHC documentation both describe .lhs as an input suffix for literate Haskell source.

Background

Literate Haskell is a convention for writing programs as explanations with embedded code, often used for teaching, research, and highly documented codebases. The Haskell 98 report defines how literate comments work and explicitly distinguishes .lhs (literate) from .hs (ordinary Haskell source).

In practical use, .lhs files are edited like any other source file in a programmer’s editor, and compiled with a Haskell compiler that supports literate input. GHC (the main Haskell compiler) recognizes .lhs and runs the literate pre-processor stage automatically as part of its compilation pipeline.

Because .lhs is plain text, it is easy to view on almost any platform. The main differences from normal Haskell source are in how tools interpret which parts are code versus documentation, so using Haskell-aware tooling is recommended when you intend to build the file.

Common MIME types: text/x-literate-haskell

Further reading

Authoritative resources for more details on the .LHS format.

Common .LHS 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.

FAQ

Is .lhs a “document file” or a “code file”?

Most commonly it is a Literate Haskell source file: a plain-text file that mixes documentation and Haskell code, intended to be edited in a text editor and compiled by a Haskell compiler.

Can I convert a .lhs to .hs by renaming it?

Renaming alone does not convert formats. Literate Haskell has documentation lines that are not valid in normal Haskell source; to convert, you must transform the literate structure into pure code according to the literate rules described in the Haskell report.

What MIME type should .lhs use?

Some systems may label it as "text/x-literate-haskell", but this is not an IANA-registered media type in the official IANA registry landing page. MIME handling can vary by platform and shared MIME database versions.

Why does GHC accept .lhs without extra flags?

GHC recognizes .lhs as a supported input suffix and runs a literate pre-processor stage as part of its compilation pipeline.

Similar file extensions

Compare related formats in the same category to find the right tool faster.