Reputation: 7394
I have tried the following:
cabal sandbox init
Then making the following cabal file.
-- Initial hsource.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: hsource
version: 0.1.0.0
-- synopsis:
-- description:
-- license:
license-file: LICENSE
author: abc
maintainer: abc
-- copyright:
-- category:
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
executable hsource
main-is: main.hs
other-modules:
-- other-extensions:
build-depends: base >=4.7 && <4.8, csv
hs-source-dirs: src
default-language: Haskell2010
Now I install the CSV package with:
cabal install --only-dependencies
Now when I try import Text.CSV
then then C-c C-l
I get the following error:
Util/RandomTree.hs:7:8-15: Could not find module ‘Text.CSV’ …
Use -v to see a list of the files searched for.
Compilation failed.
So my question is if sandboxes are not supported in haskell-mode or am I missing some steps to get them to work?
Upvotes: 2
Views: 488
Reputation: 118
Make sure you have:
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
in your emacs init file.
There are different GHCi process types supported by haskell-mode. You need one that uses cabal.
To find out what process type is currently applied, use M-x describe-variable
and enter haskell-process-type
.
I think the haskell-mode documentation is out of date; because, looking at the source code, the default is auto
, which will use cabal-repl
if it is able to locate a .cabal-sandbox directory. Otherwise, it will use ghci
.
So, if your haskell-process-type
is set to ghci
or auto
and it's unable to locate your cabal sandbox, you will see the error you posted. If it's currently set to ghci
, change the haskell-process-type
to cabal-repl
by adding:
(custom-set-variables
'(haskell-process-type 'cabal-repl))
to your emacs init file and restarting the emacs process.
Also, you can always confirm that the problem is specific to emacs by opening a command line, navigating to the directory containing your .cabal file and entering cabal repl
. If that works, then your cabal setup is fine.
Upvotes: 1