How to open .HS files on Linux
To open .HS files on Linux, to view/edit: open the .hs file in a text editor or IDE; many Linux desktops recognize it as text/x-haskell via the shared-mime-info database.
Step-by-step instructions
- To view/edit: open the .hs file in a text editor or IDE; many Linux desktops recognize it as text/x-haskell via the shared-mime-info database.
- To compile: install GHC and compile the .hs file from a shell (the GHC User’s Guide documents compiling source files such as Foo.hs).
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.
- In VS Code, install the Haskell extension (haskell/vscode-haskell).
- 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.
- Install GHC and try compiling the file according to the GHC User’s Guide (for example, compiling Foo.hs).
- 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.
- Try opening the file with a text editor explicitly (Open With → your editor).
- 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.
- Re-download or re-copy the file from the original source to avoid transfer corruption.
- 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.