OK, so now opening each file in emacs works correctly but when I try to load the test file in haskell repl, it fails complaining it cannot find the local package. 

Here is my cabal file:

Name:                 tdd-qc
Version:              1.0
Build-type:           Simple
Synopsis:             This is a sample project
License:              BSD3
License-file:         LICENSE
Author:               Arnaud Bailly <arnaud.oqube@gmail.com>
Build-Depends:        base
Cabal-version:        >= 1.8

Executable tdd-qc
  build-depends:      base
  hs-source-dirs:     src
  main-is:            tdd-qc.hs
  ghc-options:        -Wall

Test-Suite tdd-qc-test
    type:             exitcode-stdio-1.0
    hs-source-dirs:   test
    main-is:          tdd-qc-test.hs
    build-depends:    base,
                      QuickCheck >= 2.6,
                      tdd-qc


And here is my emacs settings:

;; haskell coding
(require 'auto-complete)
(require 'haskell-mode)
(require 'haskell-cabal)

(autoload 'ghc-init "ghc" nil t)

(add-hook 'haskell-mode-hook (lambda () (ghc-init)))

(eval-after-load "haskell-mode"
  '(progn
     (setq haskell-stylish-on-save t)
     (setq haskell-process-args-cabal-repl '("--ghc-option=-ferror-spans"
    "--with-ghc=ghci-ng"))     
     
     (define-key haskell-mode-map (kbd "C-,") 'haskell-move-nested-left)
     (define-key haskell-mode-map (kbd "C-.") 'haskell-move-nested-right)
     (define-key haskell-mode-map (kbd "C-c v c") 'haskell-cabal-visit-file)
     (define-key haskell-mode-map (kbd "C-c C-c") 'haskell-compile)
     (define-key haskell-mode-map (kbd "C-x C-d") nil)
     (setq haskell-font-lock-symbols t)

     ;; Do this to get a variable in scope
     (auto-complete-mode)

     ;; from http://pastebin.com/tJyyEBAS
     (ac-define-source ghc-mod
       '((depends ghc)
         (candidates . (ghc-select-completion-symbol))
         (symbol . "s")
         (cache)))
     
     (defun my-ac-haskell-mode ()
       (setq ac-sources '(ac-source-words-in-same-mode-buffers
                          ac-source-dictionary
                          ac-source-ghc-mod)))
     (add-hook 'haskell-mode-hook 'my-ac-haskell-mode)
     
  
     (defun my-haskell-ac-init ()
       (when (member (file-name-extension buffer-file-name) '("hs" "lhs"))
         (auto-complete-mode t)
         (setq ac-sources '(ac-source-words-in-same-mode-buffers
                            ac-source-dictionary
                            ac-source-ghc-mod))))
     (add-hook 'find-file-hook 'my-haskell-ac-init)))

(add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)

(eval-after-load "which-func"
  '(add-to-list 'which-func-modes 'haskell-mode))

(eval-after-load "haskell-cabal"
    '(define-key haskell-cabal-mode-map (kbd "C-c C-c") 'haskell-compile))


Thanks in advance for any advice....


--
Arnaud Bailly
FoldLabs Associate: http://foldlabs.com


On Sat, Apr 5, 2014 at 9:03 AM, Arnaud Bailly <arnaud.oqube@gmail.com> wrote:
OK, I forgot the —enable-tests flag to cabal install…

However, there seems to be some strange interactions I do not understand fully with the test section of cabal.
Here is the cabal file:

name:             Thermometre
version:          0.1.0.0
synopsis:            synopsis
-- description:
license:             PublicDomain
license-file:        LICENSE
author:              Black
-- maintainer:
-- copyright:
-- category:
build-type:       Simple
cabal-version:    >= 1.8

library
  hs-source-dirs:
      src
  exposed-modules:
      Thermometre
  build-depends:
      base    == 4.*

test-suite spec
  type:
      exitcode-stdio-1.0
  ghc-options:
      -Wall -Werror
  hs-source-dirs:
      test
  main-is:
      Spec.hs
  build-depends:
      base    == 4.*
    , Thermometre
    , hspec   >= 1.3

When I remove the test-suite section and open src/Thermometre.hs I got errors highlighting which is fine. C-c C-t does not give me types however ('Cannot guess type’ message).

When I leave the test-suite section then opening Thermometre.hs gives me a package error: ‘cannot satisfy -package Thermometre’ as there is a dependency from the tests to the main library.

How can I solve that?

Thanks
Arnaud

On 03 Apr 2014, at 23:30, Kazu Yamamoto (山本和彦) <kazu@iij.ad.jp> wrote:

>> I upgrade my emacs configuration with latest ghc-mod and all of sudden
>> nothing works (again).
>> When I try to load a .hs file from a project I got the first line
>> highlighted with the error "cannot satisfy -package spec" and I cannot got
>> type, info or doc from that file. Also I do not have anymore syntax errors
>> highlighting I used to see.
>
> As this message suggests, you need to install spec for testing.
>
> % cabal install spec
>
> # I don't know what the spec package is. A typo for hspec?
>
> This is because ghc-mod obtains dependency for executables, libraries
> *and* testing.
>
> In general,
> % cabal install --only-dependencies
> would help you.
>
> --Kazu