【问题标题】:Directory Structure Yesod and Stack目录结构 Yesod 和 Stack
【发布时间】:2016-04-18 06:58:20
【问题描述】:

我有一个简单的 Yesod 项目,其通常的目录结构如下:

./Main.hs
./Foundation.hs
./Handler/Home.hs
./Handler/... etc
./config/routes
./templates/home.hamlet
./templates/default-layout.hamlet
./templates/default-layout-wrapper.hamlet
./templates/default-layout-wrapper.cassius
...

我正在尝试使用堆栈构建这个项目,其中 Main.hs 程序通常位于 app 目录下。

我试图将所有 Yesod 结构放在 app 目录下(app 目录是上面的.)。

项目的 cabal 文件如下所示:

executable proj-web01-exe
  hs-source-dirs:      app
  main-is:             Main.hs
  ghc-options:         -threaded -rtsopts -with-rtsopts=-N
  build-depends:       base, bytestring, split, filepath
                     , stm, data-default, text, conduit, conduit-extra
                     , containers, resourcet, blaze-html, blaze-markup
                     , shakespeare, yesod, yesod-static
                     , proj-web01
  default-language:    Haskell2010

现在当我尝试stack build 时,我收到以下错误消息:

[1 of 6] Compiling Foundation       ( app/Foundation.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/proj-web01-exe/proj-web01-exe-tmp/Foundation.o )

/home/me/proj-web01/app/Foundation.hs:46:35:
    Exception when trying to run compile-time code:
      Called widgetFileNoReload on "default-layout", but no templates were found.
    Code: widgetFileNoReload (def) "default-layout"
    In the splice: $(widgetFileNoReload def "default-layout")

--  While building package proj-web01-0.1.0.0 using:
      /home/me/.stack/setup-exe-cache/x86_64-linux/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.5.0 build lib:proj-web01 exe:proj-web01-exe --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

widgetFileNoReload 不知道在哪里可以找到app/templates 目录中的“默认布局”文件。

我的问题:我应该以不同的方式编写 cabal 文件,还是应该将模板、Handler... 文件夹放在其他地方(例如在 src 中)?使用堆栈时最自然的目录结构是什么?或者如何设置堆栈参数(cabal 和 yaml 文件)以适应通常的 Yesod 目录结构?

【问题讨论】:

    标签: haskell yesod haskell-stack


    【解决方案1】:

    如果您采用标准 Yesod 脚手架,它应该可以毫无问题地使用 Stack 进行编译(事实上,我现在正在这样做)。在您熟悉设置之前,我建议您不要移动脚手架文件。如果您真的想移动源文件,我建议您将模板保留在原始位置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多