数据类型中的三重冒号 (::::) 在 Haskell 中是什么意思?
例如:
data Term = Var ID | Atom String | Nil | Term:::Term
可在本文https://gup.ub.gu.se/file/207634 中找到
将如何使用?
例如,我可以做,foo = Var "hello"但我不知道有什么用Term:::Term。
菜鸟问题:
我想改变数组列表中存在的值。我最初尝试获取索引项并直接更改其字段值。
const Foo = struct {
const Self = @This();
foo: u8,
};
pub fn main() anyerror!void {
const foo = Foo {
.foo = 1,
};
const allocator = std.heap.page_allocator;
var arr = ArrayList(Foo).init(allocator);
arr.append(foo) catch unreachable;
var a = arr.items[0];
std.debug.warn("a: {}", .{a});
a.foo = 2;
std.debug.warn("a: {}", .{a});
std.debug.warn("arr.items[0]: {}", .{arr.items[0]});
//In order to update the memory in [0] I have to reassign it to a.
//arr.items[0] = a;
}
Run Code Online (Sandbox Code Playgroud)
然而结果却出乎我的意料:
a: Foo{ .foo = 1 …Run Code Online (Sandbox Code Playgroud) 我正在尝试将外部cpp库与haskell链接.运行stack build似乎正确构建它,但当我尝试运行时,stack repl我收到此错误:
ghc: panic! (the 'impossible' happened)
(GHC version 8.0.1 for x86_64-unknown-linux):
Loading archives not supported
Run Code Online (Sandbox Code Playgroud)
app.cabal
executable app-server
...
include-dirs: /usr/local/include
extra-libraries: symengine stdc++ gmpxx gmp
...
Run Code Online (Sandbox Code Playgroud)
stack.yml
flags: {}
packages:
- '.'
extra-include-dirs:
- /usr/local/include
extra-lib-dirs:
- /usr/local/lib
extra-deps: []
extra-package-dbs: []
resolver: lts-7.1
Run Code Online (Sandbox Code Playgroud)
我在mac osx sierra和debian jessie上尝试过.使用ghc-8.0.1(来自lts-7.1).我symengine stdc++ gmpxx gmp在我的机器上安装了.
有谁知道我在这里做错了什么?