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.
;; 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)
(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....