4

I'm prototyping and messing around with the types in my program and I currently use ghc --make whenever I want to do a type check. However, this command also spends time to compile and link a real executable that I don't need just yet. Is there some flag I can pass to ghc to tell it to do just the typechecking?

hugomg
  • 68,213
  • 24
  • 160
  • 246

2 Answers2

13

Passing the -fno-code flag to ghc will do what you need.

$ ghc -fno-code myfile.hs
Chris Taylor
  • 46,912
  • 15
  • 110
  • 154
Mark Wotton
  • 632
  • 4
  • 11
3

GHCi will type-check your code and compile it, but will generally be much faster than GHC even with -O0. If that's not sufficient, there are also programs like hdevtools and ghc-mod that exist for this purpose -- they're generally meant to be integrated with a text editor but can also be used standalone.

(Another option that might speed things up a bit with just the regular compiler is -S, which stops after generating assembly without assembling or linking.)

shachaf
  • 8,890
  • 1
  • 33
  • 51