1
votes

I have a source file that will only compile with Cabal. It's test code, and in the past (before I complicated my Haskell environment) I would run functions from within ghci. I know ghci can use object files to load code, but when I try to do so I get the following error. So what am I missing?

[mlitchard@Boris Boris_Test]$ ghci /home/mlitchard/Boris_Test/dist/build/Boris_Test/Boris_Test-tmp/Main.o

GHCi, version 7.4.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading object (static) /home/mlitchard/Boris_Test/dist/build/Boris_Test/Boris_Test-tmp/Main.o ... done
final link ... ghc: /home/mlitchard/Boris_Test/dist/build/Boris_Test/Boris_Test-tmp/Main.o: unknown symbol

monadzmcontrolzm0zi3zi1zi3_ControlziMonadziTransziControl_zdfMonadBaseControlIOIO_closure' linking extra libraries/objects failed

1

1 Answers

2
votes

When you specify object files manually, GHCi can't tell what the object file depends on, which it would be able to do with .hs files, because it has access to the import ... lines in that situation.

Therefore, you need to add the object files of all the relevant dependencies manually, in this case by adding -package monad-control, when invoking GHCi.