parent
c6b74d8053
commit
ab1e4f670a
@ -0,0 +1,29 @@
|
||||
Yet Another Covid Statistics Web App
|
||||
====================================
|
||||
|
||||
During the Covid-19 pandemic it seems like everyone and their dog made a web app to display statistics, and I was part of everyone. I was working in a grocery store at the time and that means I saw a lot of people. Originally I reasoned about my risk using a spreadsheet, manually pulling in fresh statistics for my area every week or so; being a programmer I knew I could do better and I made this. The backend is written in Guile Scheme while the frontend is written in Elm, both languages were chosen due to my interest at the time.
|
||||
|
||||
If you want to run this all yourself the project depends on:
|
||||
* [Guile][gui]
|
||||
* [Artanis][art]
|
||||
* [Elm][elm]
|
||||
|
||||
It uses autoconf and make and can be deployed locally by running:
|
||||
```
|
||||
./configure; make; make install; make up
|
||||
```
|
||||
|
||||
# Notes
|
||||
## The backend
|
||||
Scheme in general has a number of features as a language that make it quite good at processing structured data. Parsers are quite easy to build in Lisp-like languages and there are entire languages (Racket) devoted to that fact. S-expressions are the primary building block of all Scheme languages, both syntax and data are just a series of S-expressions and when parsing structured data it all gets converted into a tree of S-expressions, commonly called sxml. There exist very strong means of manipulating these sxml trees, namely ```pre-post-order``` which can walk through a tree and dynamically change between depth-first and breadth-first walk orders depending on the node. In this program, data is read using a modified [csv parser][csv] and output as sxml, processed using ```pre-post-order``` to remove data from the tree we aren't interested in and label each group of data with ```hr``` before the tree is evalutated as though it's code. The ```hr``` symbol is a syntax-rule and so when the evaluation is run each Health Region's data is re-written to code associating that data with a variable by the Guile interpreter. The same basic process is used on a list associating postal codes with health regions.
|
||||
|
||||
After all that parsing and data wrangling all that's left is to serve the data using Guile's own web server [Artanis][art] which looks more or less like every other web server out there. It's very straightforward to deine routes, handle get requests and define things like return types.
|
||||
|
||||
## The frontend
|
||||
Elm is a very interesting language, it's a Haskell that compiles to Javascript. It was created as a thesis project back in 2012 as a proof of concept for something the author called functional reactive programming. The "reactive" part of that recipe is everywhere in modern web programming and common terminology like "reactive props" were coined by Elm. In it's current form Elm's reactive roots are handled under the hood, its html module is clever enough to spot dependant variables and make minimal modifications to the DOM as an app's state updates. Elm is very aggressively an MVC language, the Model and Controller types are referenced everywhere and both pass through the View and Update functions. I decided to cut up the Controller type mid-way through the project according to why something was happening and it was quite easy. Thanks to the strict type system and detailed error messages any change I missed was caught by the compiler and portioning out the update function into active and passive concerns really cleaned things up.
|
||||
|
||||
|
||||
[art]:https://www.gnu.org/software/artanis
|
||||
[gui]:https://www.gnu.org/software/guile
|
||||
[elm]:https://elm-lang.org
|
||||
[csv]:https://gitlab.com/bradymcd/guile-csv
|
||||
Loading…
Reference in new issue