我刚刚开始与haskell..尝试使用键值对..
我在reddit上看到了这个例子
https://www.reddit.com/r/haskellquestions/comments/2xn9y2/whats_the_equivalent_of_a_python_dictionary_in/
λ> import qualified Data.HashMap.Strict as M
λ> let d = M.fromList [("a", 10.33), ("c", 20.23), ("d", 100.33)]
λ> d
fromList [("d",100.33),("a",10.33),("c",20.23)]
λ> M.lookup "c" d
Just 20.23
λ> M.insert "z" 77 d
fromList [("z",77.0),("d",100.33),("a",10.33),("c",20.23)]
字符串
当我尝试运行此程序时,它给出了一个错误“:set -package unordered-containers”
当我这样做的代码运行..
我不清楚的是以下几点
1.那是什么意思?
1.这是默认设置吗?如果不是,我应该把它设为默认设置吗?
1.最后,如果我在haskell脚本中重复这个示例,我需要做什么来获得相同的设置?
我在谷歌上搜索了一下,发现它是这个包X1 E1 F1 X的一部分
当我使用堆栈创建新项目并将依赖项添加为
- 无序容器-0.2.19.1
并运行它时,会出现此错误
/Users/air/haskell/thinkingFunctionally/myproj/src/Lib.hs:4:1: error:
Could not find module ‘Data.HashMap.Strict’
Perhaps you meant
Data.Map.Strict (needs flag -package-id containers-0.6.7)
Data.IntMap.Strict (needs flag -package-id containers-0.6.7)
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
4 | import qualified Data.HashMap.Strict as M
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: [S-7282]
Stack failed to execute the build plan.
While executing the build plan, Stack encountered the error:
[S-7011]
While building package myproj-0.1.0.0 (scroll up to its section to see the error) using:
/Users/air/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_6HauvNHV_3.10.1.0_ghc-9.6.3 --verbose=1 --builddir=.stack-work/dist/x86_64-osx/ghc-9.6.3 build lib:myproj exe:myproj-exe --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
型
我的.cabal文件如下
source-repository head
type: git
location: https://github.com/githubuser/myproj
library
exposed-modules:
Lib
other-modules:
Paths_myproj
autogen-modules:
Paths_myproj
hs-source-dirs:
src
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
build-depends:
base >=4.7 && <5
default-language: Haskell2010
executable myproj-exe
main-is: Main.hs
other-modules:
Paths_myproj
autogen-modules:
Paths_myproj
hs-source-dirs:
app
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, myproj
default-language: Haskell2010
test-suite myproj-test
type: exitcode-stdio-1.0
main-is: Spec.hs
other-modules:
Paths_myproj
autogen-modules:
Paths_myproj
hs-source-dirs:
test
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, myproj
default-language: Haskell2010
型
这是我的第一个帖子,所以我希望我在这里说得有意义。
谢谢你的帮助。
编辑:尝试了同样的事情使用阴谋集团..对于任何人谁有同样的问题,我的新阴谋集团文件看起来像这样
executable myproject
main-is: Main.hs
-- Modules included in this executable, other than Main.
-- other-modules::
-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
build-depends: base ^>=4.15.1.0
,unordered-containers >=0.2.19.1
hs-source-dirs: app
default-language: Haskell2010
型
1条答案
按热度按时间c90pui9n1#
将
unordered-comtainers
添加到build-depedends
:字符串