Follow this post, install stack
first:
# pacman -S stack
resolving dependencies...
looking for conflicting packages...
......
At the end of installation, it prompts following words:
You need to either 1) install latest stable ghc package from [extra] or 2) install ncurses5compat-libs from AUR for the prebuilt binaries installed by stack to work.
So install ghc
further:
# pacman -S ghc
resolving dependencies...
looking for conflicting packages...
Now that the environment is ready, you should modify your own ~/.stack/config.yaml
file:
# This file contains default non-project-specific settings for 'stack', used
# in all projects. For more information about stack's configuration, see
# http://docs.haskellstack.org/en/stable/yaml_configuration/
# The following parameters are used by "stack new" to automatically fill fields
# in the cabal config. We recommend uncommenting them and filling them out if
# you intend to use 'stack new'.
# See https://docs.haskellstack.org/en/stable/yaml_configuration/#templates
templates:
params:
# author-name:
# author-email:
# copyright:
# github-username:
For example, add name, email etc.
Then follow this link to create a simple program:
# stack new hello
# cd hello
# stack setup
# stack build
# stack exec hello-exe
You will see “someFunc
” is outputted.
BTW, you can also use ghc
compiler directly. E.g., write a “Hello world” program (Reference is here):
# cat hello.hs
main :: IO ()
main = putStrLn "Hello World!"
# ghc -dynamic hello.hs
# ./hello
Hello World!
That’s all!