ghc-mod 的切换组件
switching component for ghc-mod
我有一个项目,其主要的 cabal 组件是一个库
library
hs-source-dirs: src
...
并且还定义了
executable todo
if !flag(example)
Buildable: False
ghc-options: -Wall
cpp-options: -DGHCJS_BROWSER
default-language: Haskell2010
hs-source-dirs: example/todo
other-modules: TodoDispatcher
TodoStore
TodoComponents
main-is: Main.hs
现在,如果我尝试键入检查一个文件,我会收到以下错误
Configuring react-flux-1.0.3...
EXCEPTION: types:
Could not find module ‘TodoDispatcher’
Use -v to see a list of the files searched for.
如果我从命令行这样做,我会得到
$ ghc-mod --ghcOpt=-v7 type example/todo/TodoViews.hs 29 28 not sandboxed
EXCEPTION: types:
Could not find module ‘TodoDispatcher’
Locations searched:
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/TodoDispatcher.hs
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/TodoDispatcher.lhs
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/TodoDispatcher.hsig
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/TodoDispatcher.lhsig
src/TodoDispatcher.hs
src/TodoDispatcher.lhs
src/TodoDispatcher.hsig
src/TodoDispatcher.lhsig
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/autogen/TodoDispatcher.hs
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/autogen/TodoDispatcher.lhs
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/autogen/TodoDispatcher.hsig
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/autogen/TodoDispatcher.lhsig
所以它似乎忽略了我尝试类型检查的当前文件所属组件的 hs-source-dirs
设置,而是考虑来自包的第一个组件的那个,就像 cabal repl 默认会做
By default cabal repl loads the first component in a package.
我怎样才能更改全局状态的那一点?
好的,为了使它正常工作,您应该执行以下操作:
您需要编辑cabal文件,将组件的flag改为
`Buildable : True`
然后您可以输入检查
$ ghc-mod --ghcOpt=-v7 type example/todo/TodoViews.hs 29 28 not sandboxed
29 24 29 34 "[Char]"
27 25 33 12 "TextInputArgs"
27 9 33 12 "ReactElementM [
在 Emacs 中:
你可能需要离开 Emacs
您需要打开文件并 haskell-process-load-file
(又名 C-c C-l,又名 Space m s b)
它应该加载正确的 "target",这是 haskell-modcabal 中 "component" 的说法。如果可行,那么 ghc-mod 也应该。 (?)
http://haskell.github.io/haskell-mode/manual/latest/Interactive-Haskell.html
14.8.1 Changing REPL target
With haskell-session-change-target you can change the target for REPL session.
After REPL session started, in haskell-interactive-mode buffer invoke the haskell-session-change-target and select from available targets for
- Testing
- Benchmark
- Executable
- Library
Answer “yes” to restart the session and run your tests, benchmarks, executables.
我有一个项目,其主要的 cabal 组件是一个库
library
hs-source-dirs: src
...
并且还定义了
executable todo
if !flag(example)
Buildable: False
ghc-options: -Wall
cpp-options: -DGHCJS_BROWSER
default-language: Haskell2010
hs-source-dirs: example/todo
other-modules: TodoDispatcher
TodoStore
TodoComponents
main-is: Main.hs
现在,如果我尝试键入检查一个文件,我会收到以下错误
Configuring react-flux-1.0.3...
EXCEPTION: types:
Could not find module ‘TodoDispatcher’
Use -v to see a list of the files searched for.
如果我从命令行这样做,我会得到
$ ghc-mod --ghcOpt=-v7 type example/todo/TodoViews.hs 29 28 not sandboxed
EXCEPTION: types:
Could not find module ‘TodoDispatcher’
Locations searched:
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/TodoDispatcher.hs
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/TodoDispatcher.lhs
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/TodoDispatcher.hsig
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/TodoDispatcher.lhsig
src/TodoDispatcher.hs
src/TodoDispatcher.lhs
src/TodoDispatcher.hsig
src/TodoDispatcher.lhsig
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/autogen/TodoDispatcher.hs
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/autogen/TodoDispatcher.lhs
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/autogen/TodoDispatcher.hsig
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/autogen/TodoDispatcher.lhsig
所以它似乎忽略了我尝试类型检查的当前文件所属组件的 hs-source-dirs
设置,而是考虑来自包的第一个组件的那个,就像 cabal repl 默认会做
By default cabal repl loads the first component in a package.
我怎样才能更改全局状态的那一点?
好的,为了使它正常工作,您应该执行以下操作:
您需要编辑cabal文件,将组件的flag改为
`Buildable : True`
然后您可以输入检查
$ ghc-mod --ghcOpt=-v7 type example/todo/TodoViews.hs 29 28 not sandboxed 29 24 29 34 "[Char]" 27 25 33 12 "TextInputArgs" 27 9 33 12 "ReactElementM [
在 Emacs 中:
你可能需要离开 Emacs
您需要打开文件并
haskell-process-load-file
(又名 C-c C-l,又名 Space m s b)
它应该加载正确的 "target",这是 haskell-modcabal 中 "component" 的说法。如果可行,那么 ghc-mod 也应该。 (?)
http://haskell.github.io/haskell-mode/manual/latest/Interactive-Haskell.html
14.8.1 Changing REPL target
With haskell-session-change-target you can change the target for REPL session.
After REPL session started, in haskell-interactive-mode buffer invoke the haskell-session-change-target and select from available targets for
- Testing
- Benchmark
- Executable
- Library
Answer “yes” to restart the session and run your tests, benchmarks, executables.