如何在 Haskell 中添加依赖项并使其对 Intero 可见

How to add dependencies and make it visible to Intero in Haskell

我想在具有 Haskell 模式和 Intero 的 emacs 中使用 System.Directory,而即时检查会警告 Couldn't find module System.Directory。所以我在我的 cabal 文件中添加了一些依赖项。当 stack build 成功执行时,警告不会消失。

下面是我的 cabal 文件:

-- This file has been generated from package.yaml by hpack version 0.28.2.
--
-- see: https://github.com/sol/hpack
--
-- hash: 536b5f6ecaaec7d4b7a9694c8f69bbe648a1d21d80fa721e533ac5b139955401

name:           find
version:        0.1.0.0
description:    Please see the README on GitHub at <https://github.com/Handora/find#readme>
homepage:       https://github.com/Handora/find#readme
bug-reports:    https://github.com/Handora/find/issues
author:         Handora
maintainer:     qcdsr970209@gmail.com
copyright:      Qian Chen
license:        BSD3
license-file:   LICENSE
build-type:     Simple
cabal-version:  >= 1.10
extra-source-files:
    ChangeLog.md
    README.md

source-repository head
  type: git
  location: https://github.com/Handora/find

library
  exposed-modules:
      Lib
      RecursiveContents
  other-modules:
      Paths_find
  hs-source-dirs:
      src
  build-depends:
      base >=4.7 && <5
    , directory
  default-language: Haskell2010

executable find-exe
  main-is: Main.hs
  other-modules:
      Paths_find
  hs-source-dirs:
      app
  ghc-options: -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      base >=4.7 && <5
    , find
    , directory
  default-language: Haskell2010

test-suite find-test
  type: exitcode-stdio-1.0
  main-is: Spec.hs
  other-modules:
      Paths_find
  hs-source-dirs:
      test
  ghc-options: -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      base >=4.7 && <5
    , find
  default-language: Haskell2010

我将 directory 添加到构建依赖项和可执行构建依赖项中。所以我的问题是如何让 System.DirectoryIntero 可见,这样警告就可以消失。

您可以通过 运行 intero-restart.

让它显示

可能有 "more correct" 方法,但这个可行。