Using inotify with Mercury

λ July 6, 2019
Tags: mercury

For now I have settled on using VSCode as my editor, having gotten fed up with the sometimes erratic indenting of the metal-mercury-mode in Emacs that I had used. Sorry ahungry!

The script

You can modify this on a per-project basis I guess but having used inotifywait in the past for many things I knew it to be just what I needed; my little helper! This simple script:

while inotifywait -e modify sdl2.m; do
  mmc -E --make sdl2 -L /usr/lib/x86_64-linux/gnu/ -lSDL2 && ./sdl2
done

Just waits until my module source changes and then re-runs the compiler and includes with the options the name of the library to link in (SDL2) and where to find those modules.

Yes…I am working on a wrapper around SDL2 as I really like that library and I have used it so much for so little for so long that I feel an overpowering urge to write a mercury wrapper just because.

One of the main differences between Haskell and Mercury is that Mercury is not lazy, it is eager. All functions calls are made as and when they are encountered although by default, as I learned this week, with the strict commutative semantics (one for another day!), sometimes the mercury compiler can choose to do things in a different order than you literally entered the code.

There are command line options that can make it perform the code in the exact same order should you so required but I am determined to learn mercury as it stands out of the box.

Comments