I'm trying to set up a Haskell project with Stack. I have created a project: stack new project1
and added the suggested dependency (acme-missile) just to see how it works.
extra-deps:
- acme-missiles-0.3
But when I try to invoke launchMissile
in the Main it won't work. I get
Error:(3, 1) Could not find module ‘Acme.Missiles’
Use -v to see a list of the files searched for.
|
3 | import Acme.Missiles
| ^^^^^^^^^^^^^^^^^^^^
What is the problem? What am I missing?
EDIT
When I run stack solver
I get this:
Using configuration file: stack.yaml
Using cabal packages:
- ./
The following changes will be made to stack.yaml:
* Dependencies to be deleted
extra-deps:
- acme-missiles-0.3
To automatically update stack.yaml, rerun with '--update-config'
Isn't that strange? Like it thinks my dependency is not needed?
You'll need to add the dependency to project1.cabal
as well:
build-depends:
base >=4.7 && <5
, project1
, acme-missiles
Alternatively, on newer versions of Stack, it looks like you should use package.yaml
instead:
dependencies:
- base >= 4.7 && < 5
- acme-missiles
I can't say that I have deep knowledge of how this works, but if I understand it correctly, the main file where you're supposed to add dependencies is in the .cabal
or package.yaml
file. The extra-deps
field in stack.yaml
is where you can indicate if you have dependencies that deviate from the LTS that you currently use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With