I'm trying to install the sbv
module https://hackage.haskell.org/package/sbv
Installation with Stack works great (no errors):
stack install sbv
but then I cannot import the corresponding module in stack ghci
:
import Data.SBV
-- <no location info>: error:
-- Could not find module ‘Data.SBV’
-- Perhaps you meant Data.Set (from containers-0.6.2.1)
Now, when I try with Cabal instead:
cabal new-install sbv --lib
Everything runs smoothly on ghci
import Data.SBV
prove $ \x -> x `shiftL` 2 .== 4 * (x::SWord8)
--- Q.E.D. (<-- this is the expected output)
However, still no luck with stack ghci
(same error as before). This is the case whether stack install sbv
was done globally or in the context of a Stack project.
Is there a way to make sbv
work with the Stack installation (even if it was installed via cabal)?
Stack has always eschewed the idea of manually installing libraries that could then be imported in files on that computer. (Cabal has more recently gone away from that too.) And there are very good reasons for this: relying on “at some point I typed this command” quickly leads to maintenance issues and duplicate work figuring out the dependencies again as soon as you try to run your code on another machine.
Thus, the recommended way is to always mention dependencies right where they're needed. For anything serious, you would use a
.cabal
(or hpack) file in your project; for smaller one-file stuff you can just make them Stack scripts.If you don't have any files at all then... well, first, you may want to consider getting a file now... but you can also use the the Stack global project, which is what
stack ghci
will by defaul use.Finally, you can also just mention the dependency right at the command line:
stack ghci --package sbv
.I don't really recommend this, unless you're really just quickly trying out something.