Requirements:
The project has the following file structure
app: contains application example and/or application mainsrc: contains application (or library) sourcestest: contains application tests
Hpack Hpack is a format for Haskell packages.
Hpack generates a .cabal file from the package.yaml file.
So, you need to create a package.yaml file (see this
example or the attached file)
All options for cabal file can be found here.
Run
hpack
to build the cabal file.
Stack is a build tool for Haskell projects.
Setup stack with
stack init
and add to the packages section the root directory of the project.
Run stack with
# build the package
stack build
# run application
stack run
# run tests
stack test
Run
cabal install
to install project dependencies.
In the test folder create a file named Spec.hs with the following content
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
Then create a folder test/APP-PACKAGE. This will contains all your tests for that package.
In the src folder create a file with the same name as your package. This will expose main functions. In the src folder can be created another folder with the name of package that contains other sources file related to your package.
Create a file Main.hs with the following content
module Main where
main :: IO ()
main = do
putStrLn "Welcome!"
# write here your code
Luca Parolari <[email protected]>