GHCi's compilation manager doesn't understand Happy grammars, but with some creative use of macros and makefiles we can give the impression that GHCi is invoking Happy automatically:
Create a simple makefile, called
Makefile_happysrcs
:
HAPPY = happy HAPPY_OPTS = all: MyParser.hs %.hs: %.y $(HAPPY) $(HAPPY_OPTS) $< -o $@
Create a macro in GHCi to replace the
:reload
command, like so (type this all
on one line):
:def myreload (\_ -> System.system "make -f Makefile_happysrcs" >>= \rr -> case rr of { System.ExitSuccess -> return ":reload" ; _ -> return "" })
Use :myreload
(:my
will do) instead of
:reload
(:r
).