2

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?

user3139545
  • 6,882
  • 13
  • 44
  • 87
  • Are you sure that you have enabled interactive-haskell-mode hook ? It seems you are using inferior-haskell-mode. – Sibi Feb 08 '15 at 18:41
  • This github issue for haskell-mode might be helpful: https://github.com/haskell/haskell-mode/issues/253 – ErikR Feb 08 '15 at 18:56

1 Answers1

1

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.

  • I have interactive-haskell-mode enabled and haskell-process-type is set to ghci. Any tips on how I can proceed to find the error? – user3139545 Feb 08 '15 at 21:04
  • So when i did set haskell-process-type to cabal-repl it fixed most of the problems. However flycheck is still underlining the text in the buffer saying that it is unable to locate the file. Any ice how to get flycheck to work? Also setting haskell-process-type to auto does not work. – user3139545 Feb 08 '15 at 21:22
  • I think this link should help: https://github.com/flycheck/flycheck/issues/293#issuecomment-31580700. – Michael Beidler Feb 08 '15 at 21:38