ocramz
ocramz

Reputation: 833

ghci cabal sandbox flags for Emacs Haskell inferior mode

I would like GHCI to have the local cabal sandbox in scope when I work in emacs. From bash, the syntax is as follows:

ghci -no-user-package-db -package-db .cabal-sandbox/*-packages.conf.d

I add the flags to inf-haskell.el , within the definition of haskell-program-name, as follows:

(defcustom haskell-program-name
  (or (cond
   ((executable-find "hugs") "hugs \"+.\"")
   ((executable-find "ghci") "ghci -no-user-package-db -package-db .cabal-sandbox/*-packages.conf.d"))
  "hugs \"+.\"")
  "The name of the command to start the inferior Haskell process.
   The command can include arguments."
   ;; Custom only supports the :options keyword for a few types, e.g. not
   ;; for string.
   ;; :options '("hugs \"+.\"" "ghci")
      :group 'inferior-haskell
      :type '(choice string (repeat string)))

but it doesn't seem to work, i.e. after reloading emacs, inspecting the value with C-h v haskell-program-name just shows it equal to "ghci", and the packages I need are of course not in scope. Any pointers? Thanks!

Upvotes: 2

Views: 426

Answers (1)

Colin Woodbury
Colin Woodbury

Reputation: 1809

After a lot of fighting, we finally figured it out: relevant Github issue

If you have haskell-process-type set to auto, and have the latest (>= 1.20.x) cabal-install in your path, running C-c C-l will open a cabal repl in emacs (even if you don't have a .cabal file around) and detect your sandbox. This lets you throw down a sandbox, quickly install a library, and then toy around with it interactively in emacs.

Good luck!

Upvotes: 1

Related Questions