Purview - A new framework for building websites

Hello hello,

I’m happy to announce the first good release of Purview. By good I mean I found myself having a good bit of fun writing a website with it.

The features, which are an assortment of things I’ve found nice across the ecosystem:

  • Side-by-side styling for HTML
  • State can be broken apart into smaller units, although you can still Elm it up and have one large event handler at the top
  • Server side rendered
  • Easy access to IO in handlers, with changes always run in green threads to avoid blocking
  • Type safe events
  • Reasonably simple interop with Javascript
  • Basic hot reloading via ghcid

My focus has mostly been on the ergonomics of use, so it’s still missing plenty and performance has not been considered at all. One aim was to be able to call an existing library of code easily and get a website going quick!

To accompany this very alpha framework, there’s a very alpha website. And, of course, the github.

I’d love to hear your thoughts and feel free to message me :slightly_smiling_face:

18 Likes

That’s neat. ghcid is a great tool, I’ve also incorporated it in my static site generator (Ema) to provide hot reload: Hot Reload – Ema

1 Like

Are there any tutorials or simple examples of using ghcid for hot reloading?

I just skimmed the docs. Looks interesting and fun. Question: If one want to use a different HTML library (e.g., blaze-html), would that be possible?

Looking at the Purview haddock, I see this

ghcid --command 'stack ghci yourProject/Main.hs' --test :main

so maybe that’s the answer to my question.

And continuing looking, I see https://github.com/srid/ema/blob/master/bin/run

It works - thanks!

You can also store the arguments in a .ghcid file (example) … then, simply running ghcid (without arguments) will work.

1 Like

Right now I don’t think it’s possible to use another HTML library but it’d be interesting to see what it’d take to allow that. Blaze-html is something I’m looking at moving all the behind the scenes HTML construction in Purview to for speeed.

And to answer your question about the hot reloading, yep it’s just using ghcid to restart the process on changes. Purview will then re-request the page on reconnection when you have devMode set to True ala

main = serve defaultConfiguration { devMode=True } yourComponent

which it does by default.

1 Like

I’ve got a bunch of blaze code that I would not want to redo.

Thanks for pointing out that code for “re-request”.