[Haskell-cafe] Separate compilation

Lars Hupel lars at hupel.info
Wed Sep 24 11:49:10 UTC 2014


Hi all,

I'm trying to compile a couple of file separately. The main purpose for
that is that we're checking student-submitted exercises, and we want to
compile them with -XSafe. The test suite doesn't require -XSafe.

There are basically three files:
* Exercise.hs -- uploaded by the student
* Exercise_Interface.hs -- imports the 'Exercise' module and creates new
bindings with appropriate types
* Exercise_Test.hs -- imports the interface module and contains the test
code and 'main'

Here's how I try to compile these files:

TEMP="$(mktemp -d -p /tmp ghcXXX)"
ghc -c -XSafe -outputdir "$TEMP" Exercise.hs
ghc -c -outputdir "$TEMP" -i"$TEMP" Exercise_Interface.hs
ghc -o "$TEMP/runner" -outputdir "$TEMP" -i"$TEMP" Exercise_Test.hs

This works except for the last step: GHC complains that it can't find
the module 'Exercise_Interface'. Upon closer inspection with '-v', it
turns out that it's actually looking for the .hs file, which I find odd.
If I add '-c' to the last invocation, it works, but I don't get an
executable. What am I doing wrong?

Cheers
Lars


More information about the Haskell-Cafe mailing list