How to open .HS files on Windows

To open .HS files on Windows, to view/edit: open the file in a code editor such as Visual Studio Code, then (optionally) install the Haskell extension (haskell/vscode-haskell) for Haskell language features.

Step-by-step instructions

  1. To view/edit: open the file in a code editor such as Visual Studio Code, then (optionally) install the Haskell extension (haskell/vscode-haskell) for Haskell language features.
  2. To compile: install GHC and run it from a terminal (for example, compile a module with a command that targets Foo.hs as input, as documented in the GHC User’s Guide).

Common issues

The file opens as plain text with no syntax highlighting or errors

Many editors treat .hs as generic text unless Haskell language support is installed/configured.

  1. In VS Code, install the Haskell extension (haskell/vscode-haskell).
  2. If the editor still doesn’t recognize it, verify the file truly ends with .hs and is not a different format renamed to .hs.

GHC compile/run fails because the environment is missing

Editing a .hs file does not require special tools, but compiling typically requires GHC and related tooling.

  1. Install GHC and try compiling the file according to the GHC User’s Guide (for example, compiling Foo.hs).
  2. If using VS Code features, ensure your Haskell toolchain is installed because the extension relies on external tooling.

Linux file type/MIME association seems wrong

Desktop environments often use the freedesktop shared MIME database to map extensions like .hs to types such as text/x-haskell, but local overrides or missing MIME data can change behavior.

  1. Try opening the file with a text editor explicitly (Open With → your editor).
  2. If you manage MIME associations on your system, confirm your environment recognizes .hs as text/x-haskell per shared-mime-info.

The file contains unreadable characters or doesn’t look like code

A real Haskell .hs file should be plain text; if it looks binary or garbled, it may be corrupted or not a Haskell source file.

  1. Re-download or re-copy the file from the original source to avoid transfer corruption.
  2. If you expected Haskell code but the content is not text, confirm with the sender/source what the file actually is before proceeding.

Security note

.hs files are plain text source code, but treating code as “data” can be risky: only compile or run Haskell code you trust, since building/running code can execute actions on your system.

Back to .HS extension page