如何安装和测试我在本地开发的 Haskell 包?

How do I install and test a Haskell package that I'm developing locally?

我正在开发一个 Haskell 包,想像安装包一样对其进行测试。也就是说,我希望能够将它安装在我的其他软件包中,然后 import:m +.

我可以成功构建我的包并且(显然)可以使用

成功安装它
cabal install

哪个报告

Resolving dependencies...
Configuring Exos-0.0.1.0...
Building Exos-0.0.1.0...
Installed Exos-0.0.1.0

但是所有导入包的尝试都失败了(例如在 GHCi 中)

<no location info>:
    Could not find module ‘Exos’
    It is not a module in the current program, or in any known package.

尽管我可以在我的 Haskell lib 目录中看到一个已填充的 Exos-0.0.1.0 文件夹。 (甚至 "uninstalling" 失败并显示 ghc-pkg unregister,报告 ghc-pkg: cannot find package Exos-0.0.1.0。)

如何安装和测试我在本地开发的包,使其表现得像我已安装的 Haskell 包集合的一部分——具体来说,以便我可以导入它(和 "uninstall" 它)和其他的一样吗?


我的包有结构

Exos.cabal
Exos/
    Cryo/
        Exos.hs
        Exos/
            Display.hs
            Core.hs

具有Exos.cabal

中的(相关)内容
name:                   Exos
version:                0.0.1.0
build-type:             Simple
- ...

library
    exposed-modules:    Cryo.Exos,
                        Cryo.Exos.Display
    other-modules:      Cryo.Exos.Core
    -- other-extensions:
    build-depends:      base >=4.8,
                        containers >= 0.5.5.1,
                        split >= 0.2.2,
                        MissingH >= 1.3.0.1
    -- hs-source-dirs:
    default-language:   Haskell2010

Exos.hs

module Cryo.Exos
    (
        f,
        g,
        otherFunc
    ) where

import Cryo.Exos.Core
-- ...

Core.hs

module Cryo.Exos.Core where
-- ...

并在 Display.hs

module Cryo.Exos.Display
    (
        showSomething,
        showSomethingElse
    ) where

import Data.Char
-- ...

import Cryo.Exos.Core
import Cryo.Exos

FWIW,在我的 IDE 中,我可以在上面的 .cabal 文件

中使用以下部分成功编写 运行 "Application"
executable enigma-hs
    main-is:            Main.hs
    build-depends:      base >=4.8,
                        Exos
    hs-source-dirs:     tests
    default-language:   Haskell2010

Exos/tests/Main.hs

中的以下(相关)代码
module Main where

import System.IO

import Cryo.Exos
import Cryo.Exos.Display

main :: IO ()
main = do
    putStr $ showSomething
    putStr $ showSomethingElse
    -- ...

错误很简单:如果您查看 Main.hs 示例,您已成功导入您拥有的模块

import Cryos.Expos

而不是

import Expos    -- wrong

那是因为,您要导入的 模块Cryos.Expos 来自 package Expos.