MicroHs in the browser

You can now run interactive mhs in your browser.
Try it!
Maybe try it on your phone. :grinning_face:

It currently only has the base package included, but it is trivial to make a version that has arbitrary packages (well, those that mhs can compile) embedded in the system.

The site consist of a small index.html (4K) and a rather hefty mhs-embed.js (2.3M). The latter contains the compiler, runtime system, and base package. It is built by emscripten to compile the C code to JS and Wasm.

Currently, you cannot access the local file system. So you cannot load or save files. That makes it rather useless. I will happily accept contributions that add file system access.

25 Likes

Cool demonstration!

I’m finding it a little hard to use; lack of arrow keys and pasting makes it tricky to navigate, and it would be nice to be able to run IO so one could do traverse (print) [1,2,3] (as was my first instinct).

I have to figure out arrow keys and pasting. But ctl-p etc work.

You can run traverse print [1,2,3] >> return (). You expression must either be IO () or have Show.

1 Like

Arrow keys and pasting should work now. There’s probably more work needed on copy&paste.

1 Like

Congrats! Amazing!

I enjoyed the still-minimal UI. I tried it as a calculator, but it’s a little floating point challenged:

> 0.5
Infinity
2 Likes

Yeah, I need to debug the FP.

I’ve uploaded a version where floating point works.

2 Likes

Could you use MicroHs to compile to (Pallas) PLAN?

Since the last step before going to combinators is untyped lambda calculus, I would think you could get PLAN from that.

You’d have avoid anything Haskell specific, say forkIO or MVar, of course.

1 Like