gpt4 book ai didi

haskell - 找不到模块 `Yesod'

转载 作者:行者123 更新时间:2023-12-02 18:41:27 24 4
gpt4 key购买 nike

我有以下代码:

{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses,
TemplateHaskell, OverloadedStrings #-}

module Simple where
import Yesod
data HelloWorld = HelloWorld

mkYesod "HelloWorld" [parseRoutes|
/ HomeR GET
|]

instance Yesod HelloWorld

getHomeR = defaultLayout [whamlet|Hello World!|]

withHelloWorld f = toWaiApp HelloWorld >>= f

main = warpDebug 3000 HelloWorld

如果在GHCI中运行,则运行正常:

Ok, modules loaded: Simple.
*Simple> main
Application launched, listening on port 3000

但是如果运行它:

wai-handler-devel 3000 Simple withHelloWorld

控制台报错:

pshuvaev@pshuvaev-K73SV:~/works/haskell/yesod/SimpleSite$ wai-handler-devel 3000 Simple.hs withHelloWorld
Attempting to interpret your app...
Compile failed:

Could not find module `Yesod'
Use -v to see a list of the files searched for.

可能是什么问题? Yesod 已设置,并显示在 ghc-pkg list 的输出中。

最佳答案

在 Unix 系统上删除 ~/.ghc 目录并运行:

ghc-pkg --global recache

在 Windows 系统上(仅建议)删除 C:\Users\USERNAME\AppData\Roaming\ghc 并从命令行重新缓存(以管理员身份):

ghc-pkg --global recache

不确定Windows!请检查!

关于haskell - 找不到模块 `Yesod',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14589358/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com