cdepillabout / pretty-simple

pretty-printer for Haskell data types that have a Show instance
https://hackage.haskell.org/package/pretty-simple
BSD 3-Clause "New" or "Revised" License
243 stars 29 forks source link

Web app #116

Closed georgefst closed 1 year ago

georgefst commented 2 years ago

Commit history is messy, This should be squash-merged. (I'm usually a stickler for clean git history, but this has been pretty error-prone and exploratory because of my lack of previous experience with GHCJS and GitHub actions)

Note that I don't intend to close https://github.com/cdepillabout/pretty-simple/issues/81 with this PR. This just gets an initial version of the app included in to this repository.

The last few points there may be worth tackling now (CI, hosting, docs). Indeed we need to do something about CI to get this PR to pass. Currently CI is trying to build the web package with some pretty old GHCs and that's not going to work. I'd be happy if we only check the Nix build on CI. I may need @cdepillabout's help with this stuff.

The rest I'm unlikely to revisit while the workflow is so awkward. Such as Miso/GHCJS still being stuck on GHC 8.6. And jsaddle-warp crashing in Firefox.

cdepillabout commented 1 year ago

This looks really good! One question, I've never used Miso or really GHCJS before, but when compiling web with normal GHC and running it, it appears that it creates a webserver on port 8000 listening on localhost that I can connect to and play around with the webapp.

Although, it looks like Firefox won't load the CSS because it gets the wrong mime type:

image

Is this just a GHCJS limitation? Or am I doing something wrong?

Also, it looks like it is sending thousands of requests:

image

You can see real small at the bottom left is says 2683 requests. Is this just how Miso/GHCJS works? Or does there seem to be some sort of problem here? Is there some way I could go about debugging this?

Oh, and I built this by just doing cabal build all using normal GHC-9.0.2.

georgefst commented 1 year ago

Although, it looks like Firefox won't load the CSS because it gets the wrong mime type

I can't reproduce (Firefox fails catastrophically for me, as mentioned in another thread, and Chromium doesn't complain), but I'd guess 692919b solves this.

Also, it looks like it is sending thousands of requests. Is this just how Miso/GHCJS works?

I'm no expert either, but I believe this is down to how JSaddle works. The production build won't have this issue.

georgefst commented 1 year ago

Shall we merge this then? The other things I think we should do right now are auto-deploy (to your github.io?) on merges to master, and put a link in the README. I'm pretty indifferent as to whether or not we do that in this PR, or separate ones.

cdepillabout commented 1 year ago

I can't reproduce (Firefox fails catastrophically for me, as mentioned in another thread, and Chromium doesn't complain), but I'd guess 692919b solves this.

Ah, I was just running cabal run web in the wrong directory. I was running it at the root, but it expects to be run in web/. I tried to clarify this in https://github.com/cdepillabout/pretty-simple/pull/119.

Shall we merge this then?

Yeah, sounds good to me! I'm completely fine if you want to tackle the deployment stuff in a separate PR.

Or this PR is fine too if it is easier for you.

georgefst commented 1 year ago

Yeah, sounds good to me! I'm completely fine if you want to tackle the deployment stuff in a separate PR.

I've started now, so I'll finish.

I've set up a Cachix cache for this project, and invited you via email. This should speed things up considerably since we actually miss Miso's cache quite a lot. But we'll need some configuration so that the GitHub Actions runner can push to this cache. As you're the owner of the repository, I think only you can do this. See here.

You might also want to take over on configuring deploy.yaml to point it to your github.io repo, and feed in the right auth tokens. I've got it as far as putting the right files on a branch in this repo. Documentation here.

When that's all done, we need to uncomment some TODOs in the YAML files before merging.

cdepillabout commented 1 year ago

I've set up a Cachix cache for this project, and invited you via email.

I never ended up getting an email about this. Would you be able to try to re-send it? You should be able to find my email in either the git history for this repo or on https://functor.tokyo/about.

I'll add the Cachix keys/tokens to this repo after I sign up.

edit: With the Miso cachix enabled, it looks like nix-building web only takes like 8 minutes. That's not too bad. I'd be fine with not having our own cachix cache if that is easier.

cdepillabout commented 1 year ago

I clicked around in the settings for a while and got the website deploying correctly from the gh-pages branch:

https://cdepillabout.github.io/pretty-simple/

Looks good!

georgefst commented 1 year ago

I never ended up getting an email about this. Would you be able to try to re-send it? You should be able to find my email in either the git history for this repo or on https://functor.tokyo/about.

I've just tried again. I previously took the email from the commit history, but maybe I made a mistake.

But actually, I think it's possible that no email needs to be sent, and you just need to sign up for Cachix. Then visit the page I used to add you.

cdepillabout commented 1 year ago

@georgefst Hey, I didn't get an email this time either. I may not have time to get to this for another week or so. How about merging this branch as is, and I can try to setup cachix in a future PR when I have some more free time?

georgefst commented 1 year ago

Sure.