Happy User Guide
Prev | Chapter 6. Tips |

# 6.5. Using Happy with GHCi

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.y

      %.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 rh (\_ -> System.system "make -f Makefile_happysrcs"
         >>= \rr -> case rr of { System.ExitSuccess -> return ":reload" ;
                                 _ -> return "" })

- Use `:myreload` (`:my` will do) instead of `:reload` (`:r`).

Prev | Home |
Conflict Tips | Up |