dmjio / miso

:ramen: A tasty Haskell front-end framework
https://haskell-miso.org
BSD 3-Clause "New" or "Revised" License
2.19k stars 139 forks source link

Integration with Linters #432

Closed AesaKamar closed 5 years ago

AesaKamar commented 6 years ago

I would like to be able to use tools like ghc-mod and hdevtools with this project.

I've been able to successfully build some of the example projects with ghcjs via nix

However, I'm unable to get linting tools to work. This has more generally been a problem I've found in using front-end Haskell libraries using ghcjs and nix.

Any suggestions for how I would be able to remedy this?

AesaKamar commented 6 years ago

I, and others it seems, have found similar difficulty using reflex, another Haskell front-end library which uses a similar approach to builds. https://github.com/reflex-frp/reflex-platform/issues/18

dmjio commented 6 years ago

@AesaKamar This PR should resolve that issue. https://github.com/dmjio/miso/pull/441

AesaKamar commented 6 years ago

Outstanding! Thanks for the update 🍜

dmjio commented 6 years ago

@AesaKamar, this should be possible now.

AesaKamar commented 6 years ago

Once I do some testing, I'll note it here and close the issue out.

dmjio commented 6 years ago

@AesaKamar sounds great!

AesaKamar commented 6 years ago

Still no luck getting the Nix build via GHCJS and ghc-mod to play nicely together. (Specifically on OSX)

I'll take another stab at integration with intero.

dmjio commented 6 years ago

@AesaKamar, I'd check out using miso with jsaddle. This way you can use ghcid, ghc-mod, etc.

git clone https://github.com/dmjio/miso
cd miso
nix-shell jsaddle.nix -A miso-shell.env
cabal new-run -f+jsaddle mario
dmjio commented 5 years ago

@AesaKamar let me know if this should be re-opened. jsaddle is still supported with miso and has helped with cross-compilation support to ARM. For day-to-day work in building websites I normally do not use it. I just use a tool like entr to detect file changes and invoke cabal build. Then use nix-shell --run web-runner in its own shell for the server, and nix-shell --run web-runner shell-ghcjs.nix in another shell. The server will serve the static assets from the static folder, the client automatically copies them into static upon successful build. The functions below are defined in the shellHook section of the shell.nix and shell-ghcjs.nix

Server compilation:

   function web-runner() {
      entr time -c 'runghc Setup.hs configure --disable-optimization --builddir=dist-web\
         \&\& runghc Setup.hs build web --builddir=dist-web \
         \&\& dist-web/build/web/web'
    }

Client compilation:

    function research-runner() {
      mkdir -p static/
      runghc util/Runner.hs runghc Setup.hs configure --disable-optimization --ghcjs --build-dir=dist-web-ghcjs \
         \&\& runghc Setup.hs build web-client --builddir=dist-web-ghcjs\&\&\
         cp -v dist-web-ghcjs/build/web-client/web-client.jsexe/all.js static/all.js \&\&\
         cp -v web/client/style.css static/style.css \&\&\
         cp -v web/*.png static/ \&\&\
         cp -v web/common/*.ico static/
    }