Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Faster compilation for Haskell Miso

I use the Haskell Miso framework to write frontend web apps and the Nix compilation process takes a long time.

How can I speed it up?

Or what is the recommended approach to have a near instantaneous edit-compile-run cycle?

like image 203
Sridhar Ratnakumar Avatar asked Aug 12 '17 14:08

Sridhar Ratnakumar


1 Answers

(Credit goes to NickSeagull)

For faster edit-compile-run cycle it is recommended to use GHCJSi as follows.

First, enter the Nix configured shell environment:

nix-shell -A env

Then, enter the GHCJSi shell:

cabal configure --ghcjs
cabal repl

GHCJSi starts up a web server. You should immediately connect to it from the web browser via http://localhost:6400/

From the GHCJSi shell--and everytime Main.hs changes--recompile and send the new code to the browser:

> import Miso.Dev  # Once
> :r
> clearBody >> main

The UI in the web browser will now update automatically with the new code. Happy hacking!

Example project

like image 112
Sridhar Ratnakumar Avatar answered Oct 21 '22 08:10

Sridhar Ratnakumar