Tuesday, June 14, 2011

Almost a Quine

To allow reloading from GHCi to trigger all the necessary Cabal preparation, I need to define macros to shadow the default commands (:r, :l, etc) . The basic idea for each of these macros is pretty simple:
  • Call whatever programs needed for preparing the package for building
  • Un-define the command so that the default behavior returns
  • Call the default command
  • Respecify the custom implementation
  • Redefine the command
Each of these macros must thus define itself again, creating a macro within a macro. Naturally, as this behavior is shared by all the overloaded GHCi commands, I created a macro to abstract this pattern. That's a string defining a macro to make a macro to make a macro. While this kind of thing is fine (almost expected) in Lisp, it doesn't work quite so well in Haskell, especially as syntax is just represented as a string.

No comments:

Post a Comment