I am just starting out with haskell.. trying out use of key value pairs..
came across this example on reddit
λ> 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)]
when i try to run this it gives an error ':set -package unordered-containers'
When i do that the code runs..
What i am not clear is the following
what does it mean?
is that setting default? if not should i make it default?
Lastly if i repeat the example in a haskell script what do i need to do to get the same setting?
I searched on google and found that it is a part of this package https://hackage.haskell.org/package/unordered-containers-0.2.19.1/docs/Data-HashMap-Strict.html
When i create a new project using stack and add dependency as
and run it it gives this error
/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
my .cabal file is as under
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
This is my first post .. so i hope i am making sense here
thanks in advance for helping out..
Edit: Tried the same thing using cabal.. for anyone who has the same issue my new cabal file looks like this
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
Add the unordered-comtainers
to the build-depedends
:
library
# …
build-depends:
base >=4.7 && <5
unordered-containers >=0.2.19.1