gpt4 book ai didi

haskell - 如何将我的 Haskell 包的文档获取到 Hackage 上?

转载 作者:行者123 更新时间:2023-12-02 02:11:52 25 4
gpt4 key购买 nike

UPDATE: This question is now out of date. Hackage now uses Haskell version 7.10.2 to build, so the following failure does not occur. The change also appears to have broken some of the scripts mentioned in the answers.



如何将我的 Haskell 包的文档获取到 Hackage 上?

我了解 Hackage 将构建它们的内容,但出现错误
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: MyPackage-0.1.0.2 (user goal)
next goal: base (dependency of MyPackage-0.1.0.2)
rejecting: base-4.7.0.1/installed-e4b... (conflict: MyPackage => base>=4.8 &&
<4.9)
rejecting: base-4.8.1.0, 4.8.0.0, 4.7.0.2, 4.7.0.1, 4.7.0.0, 4.6.0.1, 4.6.0.0,
4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0, 4.3.0.0, 4.2.0.2, 4.2.0.1,
4.2.0.0, 4.1.0.0, 4.0.0.0, 3.0.3.2, 3.0.3.1 (global constraint requires
installed instance)
Dependency tree exhaustively searched.

我无法降低我的包的要求(这似乎是自动构建的障碍),我看到一些包说“用户上传的文档”。但是,任何构建尝试都会失败(见下文。)

如何将我的 Haskell 包的文档获取到 Hackage 上?特别是,我需要做什么才能自己上传它们?

我有 tried
$ cp -R ./dist/doc/html/MyPackage/ MyPackage-0.1.0.2-docs
$ tar cvzf --format=ustar -f MyPackage-0.1.0.2-docs.tar.gz MyPackage-0.1.0.2-docs
$ curl -X PUT -H 'Content-Type: application/x-tar' -H 'Content-Encoding: gzip' --data-binary '@MyPackage-0.1.0.2-docs.tar.gz' 'https://hackage.haskell.org/package/MyPackage-0.1.0.2/docs' -u 'Rax'

但得到

Invalid documentation tarball: File in tar archive is not in the expected directory 'MyPackage-0.1.0.2-docs'


name:                   MyPackage
version: 0.1.0.2
license: BSD3
license-file: LICENSE
-- copyright:
category: Development
build-type: Simple
-- extra-source-files:
cabal-version: >= 1.22.1.1

library
-- default-extensions: Trustworthy
exposed-modules: MyMod.A,
MyMod.A.B
other-modules: MyMod.C
-- other-extensions:
build-depends: base >= 4.8.1.0 && <4.9,
containers >= 0.5.5.1,
split >= 0.2.2,
MissingH >= 1.3.0.1
-- hs-source-dirs:
default-language: Haskell2010

我也尝试了下面链接的几个脚本的我自己的版本,但得到了同样的错误:
#!/bin/bash

cabal haddock --hyperlink-source --html-location='/package/$pkg-$version/docs' --contents-location='/package/$pkg'
S=$?
if [ "${S}" -eq "0" ]; then
cd "dist/doc/html"
DDIR="${1}-${2}-docs"
cp -r "${1}" "${DDIR}" && tar -c -v -z --format=ustar -f "${DDIR}.tar.gz" "${DDIR}"
CS=$?
if [ "${CS}" -eq "0" ]; then
echo "Uploading to Hackage…"
curl -X PUT -H 'Content-Type: application/x-tar' -H 'Content-Encoding: gzip' --data-binary "@${DDIR}.tar.gz" --digest --netrc "https://hackage.haskell.org/package/${1}-${2}/docs"
exit $?
else
echo "Error when packaging the documentation"
exit $CS
fi
else
echo "Error when trying to build the package."
exit $S
fi

我用它调用
myscript MyPackage 0.1.0.2

但得到同样的错误。

最佳答案

您的图书馆是否需要 base >= 4.8.1.0 ?

这就是问题所在 - Hackage 正在尝试使用 base == 4.7.0.1这与您的 cabal 文件冲突。

我想看看您是否可以使用 Hackage 使用的基础构建您的库。

一些将文档上传到 Hackage 的链接:

  • http://fuuzetsu.co.uk/blog/posts/2014-01-06-Fix-your-Hackage-documentation.html
  • https://gist.github.com/stbuehler/7068764
  • 关于haskell - 如何将我的 Haskell 包的文档获取到 Hackage 上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32768787/

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