我尝试在 Window 10 上使用 cabal 安装库的每一次努力都导致了同样的错误:
cabal install gtk
cabal.exe: Could not resolve dependencies:
[__0] trying: parconc-examples-0.4.8 (user goal)
[__1] next goal: base (dependency of parconc-examples)
[__1] rejecting: base-4.15.0.0/installed-4.15.0.0 (conflict: parconc-examples
=> base>=4.5 && <4.14)
[__1] skipping: base-4.15.0.0, base-4.14.2.0, base-4.14.1.0, base-4.14.0.0
(has the same characteristics that caused the previous version to fail:
excluded by constraint '>=4.5 && <4.14' from 'parconc-examples')
[__1] rejecting: base-4.13.0.0, base-4.12.0.0, base-4.11.1.0, base-4.11.0.0,
base-4.10.1.0, base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0,
base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, base-4.7.0.1, base-4.7.0.0,
base-4.6.0.1, base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, …Run Code Online (Sandbox Code Playgroud) data D = A Int Int | B Int Char
instance Show D where
show (A a b) = show b
show (B a b) = show b
hehe :: D -> String
hehe d = show u ++ show v
where (u, v) = show <$> case d of
A a b -> (a + 1, b)
B a b -> (a + 2, b)
Run Code Online (Sandbox Code Playgroud)
我的想法是,我想在元组上应用函数,但它不进行类型检查,因为元组的第二个元素可以是 anInt或 a Char。
这是错误消息:
* Couldn't match expected type `Int' …Run Code Online (Sandbox Code Playgroud)