[ANN] - Hugs for MacOS (x86) - via Nix Flakes

I spent some time with the last public release of the Hugs sources, making them compile on a modern Mac (x86 chipset). I used Nix’s flakes feature to manage the build and install.

If you’d like to run the hugs interpreter directly using the flake, just type:

nix run github:m4dc4p/hugs#hugs

If you’d like to execute a Haskell file, try:

nix run github:m4dc4p/hugs <file.hs>

Or alternately:

nix run github:m4dc4p/hugs#runhugs <file.hs>

(That is, runhugs is the default app provided by the flake.)

See the README at GitHub - m4dc4p/hugs: Hugs Interpreter for more details (including other apps available).

I don’t have much of a use case for Hugs, so I got the flake to the point where I could start the interpreter and run simple programs. I’m glad to accept pull requests or bug reports. You can find the source and submit any issues at GitHub - m4dc4p/hugs: Hugs Interpreter.

Note: I don’t have access to Apple silicon, so this build has only been tested under x86. If it works for M1 please let me know, or if you are able to submit a PR I’d welcome it!

10 Likes

That’s an interesting source choice: I was tinkering with Hugs about 18 months ago - like you, I used:

https://www.haskell.org/hugs/downloads/2006-09/hugs98-plus-Sep2006.tar.gz

…but remediating the atrophied Cabal support was of little interest to me. I instead used:

  • http://deb.debian.org/debian/pool/main/h/hugs98/hugs98_98.200609.21.orig.tar.gz
  • http://deb.debian.org/debian/pool/main/h/hugs98/hugs98_98.200609.21-5.4.diff.gz

(Despite being officially maintainer-less, it still sees some occasional maintenance.)

If you’re interested, I have two series of patches which:

  • replace the conservative-GC mechanism with an accurate one base on a shadow stack (inspired by, and an “abstract interpretation” of the mechanism used in the Nickle system)

  • finally retire the old “K&R”-format C declarations.

(There are other series, but I’m not sure if they would be of any use for you.)


That was fortunate (or a wise choice ;-) - my tinkering was on an x86-64 system, where the FFI support is “incomplete” .

From mkThunk() in src/builtin.c:

/* line 2056 */
#if i386_HOST_ARCH

/* line 2073 */
#elif powerpc_HOST_ARCH && defined(__GNUC__)

/* line 2122 */
#elif sparc_HOST_ARCH && defined(__GNUC__)

/* line 2181 */
#else
    ERRMSG(0) "Foreign import wrapper is not supported on this architecture"
    EEND;
#endif

(…I don’t recall if foreign exports are supported, though.)

So for all I know, my patches may have affected FFI support on (32-bit) x86 systems - it’s something you would have to be wary of :-(

1 Like

Sure, I’d love to see them. That diff applied cleanly to the same sources I have (no surprise). Checking now to see how well it plays with the diff I had to produce to get the sources to build …