Haskell Language Stack Structure


File structure

A simple project has the following files included in it:

➜  helloworld ls 
LICENSE          Setup.hs         helloworld.cabal src              stack.yaml

In the folder src there is a file named Main.hs. This is the "starting point" of the helloworld project. By default Main.hs contains a simple "Hello, World!" program.


module Main where

main :: IO ()
main = do
  putStrLn "hello world"

Running the program

Make sure you are in the directory helloworld and run:

stack build # Compile the program
stack exec helloworld # Run the program
# prints "hello world"