.hs

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.

Category
Code and data
Type
Plain text
Is a .hs file safe to open? Caution. A .hs file is program source. Compiling and running it executes its code; review unfamiliar files first.

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.

How to open 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. For a step-by-step walkthrough, see how to open a .hs file.

Windows

  • VS Code (Haskell)
  • GHCi
  • any text editor

macOS

  • VS Code (Haskell)
  • GHCi
  • any text editor

Linux

  • VS Code (Haskell)
  • GHCi
  • any text editor

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.

.hs file signature (magic bytes)

Programs recognise a .hs file by the bytes at the start of the file, not by its name. These are the signatures for Haskell.

Hex signatureOffsetNote
(no fixed signature)0plain text; no fixed magic bytes

See the full magic-numbers reference for every format.

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: