What is a .hs file?
Haskell Source File · Code and data · Haskell Committee · 1990
A .hs file is Haskell source code, a purely functional programming language known for its strong type system and lazy evaluation. It is used in research, finance and anywhere correctness matters.
What is a .hs file used for?
Haskell is purely functional: functions have no side effects by default, and the compiler's powerful type system catches many errors before the program runs. It compiles to fast native code with GHC, the standard compiler.
The files are plain text; VS Code with the Haskell extension, backed by GHC and the tools cabal or stack, is a common setup.
What opens a .hs file?
The .hs format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list.
Windows
- VS Code (Haskell)
- GHCi
- any text editor
macOS
- VS Code (Haskell)
- GHCi
- any text editor
Linux
- VS Code (Haskell)
- GHCi
- any text editor
Open a .hs file step by step
- Confirm the file really is a .hs. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
- On Windows, open it with VS Code (Haskell) or GHCi.
- On Mac, use VS Code (Haskell) or GHCi.
- On Linux, try VS Code (Haskell) or GHCi.
- Still stuck? Convert the .hs to exe (via GHC), which opens more widely.
Why can't I open my .hs file?
Almost always because no installed app understands Haskell. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.
The other possibility is that the file is not really a .hs at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.
How to convert a .hs file
You can convert a .hs file to exe (via GHC) using a conversion tool or the export menu of an app that opens it.
Haskell has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.
Frequently asked questions
What is a .hs file?
A .hs file is Haskell source code, a purely functional programming language known for its strong type system and lazy evaluation. It is used in research, finance and anywhere correctness matters.
How do I run a .hs file?
Load it in GHCi (the interactive Haskell shell) with ghci file.hs, or compile it with ghc file.hs and run the resulting binary. The tools stack and cabal manage projects.
What makes Haskell different from other languages?
It is purely functional and lazily evaluated, with a strong static type system. Side effects are tracked in the types, which makes programs predictable and easy to reason about.
How do I open a .hs file?
Any text editor shows the source. VS Code with the Haskell extension adds type hints, errors and completion.
Related formats
Sources
Details on this page were checked against authoritative references. How sources are ranked and what is deliberately left out is set out in the methodology.