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?
Asked
Active
Viewed 655 times
4

ДМИТРИЙ МАЛИКОВ
- 21,474
- 11
- 78
- 131

hugomg
- 68,213
- 24
- 160
- 246
-
1I just added a caveat to the answer that was given to me: in-exhaustive patterns are not checked. – Christopher Done Jul 30 '13 at 08:07
2 Answers
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