How can packages be hidden when using only the stack?

I would like to try Monad Writer in ghci. As advised here , I tried to use only the stack to manage GHC and packages and avoid a global installation.

From a new install of Ubuntu 15.04 after installing the stack:

 stack setup mkdir lyah && cd lyah stack new stack install mtl stack ghci ghci> import Control.Monad.Writer Could not find module 'Control.Monad.Writer' It is a member of the hidden package 'mtl-2.1.3.1'. 

I understand that pre-stack ghc-pkg was used to show / hide packages, but I'm not sure how to go here to "show" the mtl package.

+6
source share
2 answers

Edit the .cabal stack new file and add mtl to the build-depends section. This part of the file should look like this:

 build-depends: base >= 4.7 && < 5 , mtl 

Then do a stack build to stack ghci .

By the way, do not use stack install to install libraries - this is just a shortcut for copying binary files. For instance. stack install hlint first build the package and then copy the resulting binary to ~ / .local / bin /. Instead, always add packages to the .cabal file, as shown above, and use stack build to have them installed.

+12
source

Since you work in GHCi, you can simply change the command line passed to the underlying GHC. For example, I did this recently:

 Prelude> import qualified GI.Gtk as Gtk <no location info>: error: Could not load module 'GI.Gtk It is a member of the hidden package 'gi-gtk-3.0.31. Perhaps you need to add 'gi-gtk to the build-depends in your .cabal file. It is a member of the hidden package 'gi-gtk-3.0.27. Perhaps you need to add 'gi-gtk to the build-depends in your .cabal file. Prelude> :set -package gi-gtk-3.0.27 package flags have changed, resetting and loading new packages... Prelude> import qualified GI.Gtk as Gtk Prelude Gtk> 
0
source

All Articles