Compilation error using MicroHS (main.c eval.c)

I’ve dipped my toes into MicroHs and I’m running into a compilation error when I try to invoke it from an external directory. The Haskell code is simply the default hello world from a cabal init

 ( ../MicroHs/bin/mhs
 -i../MicroHs/lib
 -I../MicroHs/src/runtime
 -I../MicroHs/src/runtime/unix
 -I../MicroHs/src
  app/Main.hs -o out )
cc1: fatal error: ./src/runtime/main.c: No such file or directory
compilation terminated.
cc1: fatal error: ./src/runtime/eval.c: No such file or directory
compilation terminated.

/home/deepak/code/haskell/mhsb/../MicroHs/bin/mhs: uncaught exception: error: command failed: cc  -I./src/runtime -I./src/runtime/unix  -D__MHS__ '-I../MicroHs/src/runtime' '-I../MicroHs/src/runtime/unix' '-I../MicroHs/src'  ./src/runtime/main.c ./src/runtime/eval.c /tmp/mhsc6idpMa.c  -oout

It seems that mhs is still trying to find main.c and eval.c in the current directory, and -I../MicroHs/src does not seem to be the right flag to pass to resolve those files elsewhere. I can get it to work by symlinking or running from the MicroHs directory, but my hope was to get it working with guix

2 Likes

The solution here was to set MHSDIR

 with-env { MHSDIR:"../MicroHs" } { ( ../MicroHs/bin/mhs
  app/Main.hs -o out ) }
:  ./out
Hello, Haskell!

Did you do make install?

All you should have to do is to extend your PATH so it can find the installed mhs and it should just work.

1 Like

I didn’t do a make install in this case because I will be creating a guix derivation that will put the package into the store (GNU alternative to nix https://guix.gnu.org/en/blog/2021/building-derivations-how-complicated-can-it-be/ )