构建 Haskell 项目的最新标准工作流程是什么?

What is the up-to-date standard workflow for building Haskell projects?

由于事情变化如此之快,我发布了这个问题,希望社区同意的启动 Haskell 项目的方式能够得到澄清。假设我有两个独立的项目:

从一台安装了 GHC 7.10.2、Stack 和 Cabal 以及一个目录 ~/OrganizeMe 的计算机开始,其中包含 ~/OrganizeMe/Square.hs~/OrganizeMe/Hypotenuse.hs~/OrganizeMe/Main.hs,如上所示 - 有经验的 Haskeller 会使用哪些完整的 unix 命令来构建这些项目? 包括:

  1. 整理那些项目的目录树;

  2. 配置 Stack/Cabal/etc(和 git,可选);

  3. building/installing 他们在本地;

  4. 发布到 Hackage/Stackage.

这不是一个完整的答案,它不是从您的 OrganizeMe 目录开始的(您的代码中有一些错误),也不包括发布到 Hackage/Stackage。我从目录 stackenv 开始包含这两个包,但您当然可以完全不同地这样做。

mkdir stackenv && cd stackenv/
mkdir square && cd square
vim Square.hs # The file you describe without the x in the type of square
cabal init # Go through the questions and choose "library"
stack init
cd ../ && mkdir hypotenuse && cd hypotenuse/
vim Hypotenuse.hs # The file you describe
vim Main.hs # The file you describe but importing Hypotenuse
cabal init # Go through the questions... "executable" this time
stack init
vim hypotenuse.cabal # add "square" or chosen package name to build-depends
vim stack.yaml # add "- '../square/'" below packages
stack install
hypotenuse 3 4 # works because ~/.local/bin is in my PATH

希望对您有所帮助。