You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何实现特定位宽的Haskell二进制数据类型?

自定义特定位宽二进制数类型及bv-sized包安装失败问题

我需要创建一个表示特定位宽二进制数的数据类型,例如bin3对应3位二进制数(格式为0bXXX),bin7对应7位二进制数(格式为0bXXXXXXX)。之前尝试通过cabal install bv-sized安装相关包来实现,但构建失败,因此计划自行实现该类型。

安装bv-sized时的错误日志

$ cabal install bv-sized
Resolving dependencies...
Configuring parameterized-utils-2.1.2.0...
Building parameterized-utils-2.1.2.0...
Failed to install parameterized-utils-2.1.2.0
Build log ( /home/.../.cabal/logs/ghc-8.2.2/parameterized-utils-2.1.2.0-4VdYssETRDcLceu2pgYcjQ.log ):
cabal: Entering directory '/tmp/cabal-tmp-99266/parameterized-utils-2.1.2.0'
Configuring parameterized-utils-2.1.2.0...
Preprocessing library for parameterized-utils-2.1.2.0..
Building library for parameterized-utils-2.1.2.0..
[ 1 of 32] Compiling Data.Parameterized.Compose ( src/Data/Parameterized/Compose.hs, dist/build/Data/Parameterized/Compose.o )

src/Data/Parameterized/Compose.hs:30:45: error:
    Type variable ‘k’ used in a kind.
    Did you mean to use TypeInType?
    the type signature for ‘testEqualityComposeBare’
   |
30 | testEqualityComposeBare :: forall k l (f :: k -> *) (g :: l -> k) x y.
   |                                             ^

src/Data/Parameterized/Compose.hs:30:59: error:
    Type variable ‘l’ used in a kind.
    Did you mean to use TypeInType?
    the type signature for ‘testEqualityComposeBare’
   |
30 | testEqualityComposeBare :: forall k l (f :: k -> *) (g :: l -> k) x y.
   |                                                           ^

src/Data/Parameterized/Compose.hs:30:64: error:
    Type variable ‘k’ used in a kind.
    Did you mean to use TypeInType?
    the type signature for ‘testEqualityComposeBare’
   |
30 | testEqualityComposeBare :: forall k l (f :: k -> *) (g :: l -> k) x y.
   |                                                                ^
cabal: Leaving directory '/tmp/cabal-tmp-99266/parameterized-utils-2.1.2.0'
cabal: Error: some packages failed to install:
bv-sized-1.0.3-Ip13iwUWQ7u421I8e2amlq depends on bv-sized-1.0.3 which failed
to install.
parameterized-utils-2.1.2.0-4VdYssETRDcLceu2pgYcjQ failed during the building
phase. The exception was:
ExitFailure 1

使用的GHC版本为8.2.2。


内容的提问来源于stack exchange,提问作者confusedandsad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 20:58:22