the stack command stack new my-project
creates a auto-generated file Setup.hs with contents:
import Distribution.Simple
main = defaultMain
but my vs code intellisense just tells me
Could not load module ‘Distribution.Simple’ It is a member of the hidden package ‘Cabal-3.2.1.0’. You can run ‘:set -package Cabal’ to expose it. (Note: this unloads all the modules in the current scope.)
so I tried to install the distribution package via command
stack install distribution
However I got the following message:
WARNING: Ignoring distribution's bounds on containers (==0.5.*); using containers-0.6.5.1.
Reason: allow-newer enabled.
WARNING: Ignoring distribution's bounds on random (==1.1.*); using random-1.2.0.
Reason: allow-newer enabled.
distribution> configure
distribution> Configuring distribution-1.1.1.0...
distribution> build
distribution> Preprocessing library for distribution-1.1.1.0..
distribution> Building library for distribution-1.1.1.0..
distribution> [1 of 8] Compiling Data.Distribution.Core
distribution>
distribution> Data\Distribution\Core.hs:173:10: error:
distribution> • Could not deduce (Semigroup (Distribution a))
distribution> arising from the superclasses of an instance declaration
distribution> from the context: (Ord a, Monoid a)
distribution> bound by the instance declaration
distribution> at Data\Distribution\Core.hs:173:10-53
distribution> • In the instance declaration for ‘Monoid (Distribution a)’
distribution> |
distribution> 173 | instance (Ord a, Monoid a) => Monoid (Distribution a) where
distribution> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
distribution>
-- While building package distribution-1.1.1.0 (scroll up to its section to see the error) using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_3.2.1.0_ghc-8.10.7.exe --builddir=.stack-work\dist\274b403a build --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
The error means that you have that package installed, but it is not listed as a dependency in your project. You need to add it in the package.yaml
in library/dependencies
or your exe:
library:
source-dirs: src
dependencies:
- Cabal
(also note that the package you miss is Cabal
as stated in the message, not distribution
which is just a module name)