0

I have a Stack based project and with the following:

ghcid --command 'stack ghci' --allow-eval --clear --no-height-limit '-o ghcid.log' I can have ghcid execute/evaluate a function as follows:

-- $> unit_simple_single
unit_simple_single :: IO ()
unit_simple_single = runTest 1 superSimplSuite

If I switch the project from Stack to Cabal and run:

ghcid --command 'cabal repl' --allow-eval --clear --no-height-limit '-o ghcid.log'

I get:

<interactive>:28:1-18: error:
    Variable not in scope: unit_simple_single

I understand that Stack does a lot of work introspecting modules in a project and loading them when you call stack ghci and cabal repl doesn't, so I guess I need to create a .ghci file but I haven't been able to get this to work.

eg.

:load SuiteRuntimeTest

I still get the same result.

So what needs to go into .ghci to get ghcid eval working? Is there a utility, like an "hpack for ghci", that could generate this file?

duplode
  • 33,731
  • 7
  • 79
  • 150
John Walker
  • 513
  • 4
  • 16

1 Answers1

0

Answer turned out to be pretty simple.

Just list all lib modules (exposed-modules and extra-deps) in the :load (:l) and :module (:m) property in the .ghci file

e.g.

Myproject\.ghci - a four module project

:l AuxFiles Check Common DSL 

:m AuxFiles Check Common DSL 
John Walker
  • 513
  • 4
  • 16