小编vro*_*911的帖子

TypeFamilies或GADT突然中断了有效代码

我有非常无辜的代码

data Config = Config
    { cInts    :: [Int]
    , cStrings :: [String] }

instance Semigroup Config where
    c1 <> c2 = Config
        { cInts    = andCombiner cInts
        , cStrings = andCombiner cStrings }
      where
        andCombiner field = field c1 <> field c2
Run Code Online (Sandbox Code Playgroud)

它编译并正常工作.但是,如果我添加TypeFamiliesGADTs扩展我看到非常奇怪的错误:

.../Main.hs:19:22: error:
    • Couldn't match type ‘Int’ with ‘[Char]’
      Expected type: [String]
        Actual type: [Int]
    • In the ‘cStrings’ field of a record
      In the expression:
        Config {cInts = andCombiner cInts, cStrings …
Run Code Online (Sandbox Code Playgroud)

haskell type-inference type-families gadt

8
推荐指数
1
解决办法
106
查看次数

如何使用共享库运行LLVM解释器?

我有mylib.c一些有一些功能的文件.我想.c在编译的llvm代码中使用我的文件中的那些函数作为外部函数.我正在玩LLVM解释器(lli-4.0),我想知道如何lli使用我的.c文件中的函数?

llvm dynamic-linking lli

3
推荐指数
1
解决办法
453
查看次数

奇怪的堆栈重击错误: - :找不到命令

我有一个非常简单的haskell项目,只有可执行文件my-exec.它所做的就是打印"Hello,world!" 控制台.

我想创建脚本文件bin/setup.sh,它将运行我的可执行文件,也做一些echo

#!/usr/bin/env stack
-- stack exec bash

echo Echo printing
my-exec
Run Code Online (Sandbox Code Playgroud)

当我跑它时,我得到了

$ ./bin/setup.sh
./bin/setup.sh: line 2: --: command not found
Echo printing
Hello, world!
Run Code Online (Sandbox Code Playgroud)

我不明白这个文件的问题是什么,为什么它说--: command not found但仍然按预期工作.

我知道在这个简单的例子中我可以用更容易的形式编写它,但在我的实际情况中,我必须做10个非平凡的exec调用,并且不想stack exec多次重复.

那么我该怎么做才能摆脱这个错误呢?

bash haskell haskell-stack

1
推荐指数
1
解决办法
815
查看次数