/7guis

🎨 Elm implementation of the 7 GUIs project

Primary LanguageElmMIT LicenseMIT

7 GUIs in Elm

Netlify Status

This is an Elm implementation of the 7 GUIs project. See the GUIs on the live site or scroll down for more info on each one.

General approach

Each GUI is a standalone program with its own Elm file. All of the programs are embedded on the main page of the site for ease of viewing.

To keep the focus on Elm, I've kept the use of styling here to the bare minimum.

Counter

A counter that counts up and down is the classic intro-to-elm example. The 7guis variant is even simpler because it only counts up. It is simple enough that one can realistically attempt to play code golf.

I chose to write the code in a more standard style, even where it wasn't strictly necessary. For example, I defined a Msg type even though there is only a single message variant.

screenshot of counter

Temperature Converter

This GUI provided two main challenges. Firstly, the (mostly) bi-directional flow. Typing into either input affects the value of the other (except if invalid input is typed). Normally I'd want to store a single value as the source of truth but the edge-cases mean I actually need to keep track of two values.

Secondly, the intuitive thing is to store a float but parsing a float out of a string is a lossy operation. For example, "1.0" and "1.00" both parse out to the same float. See this example of how that can break things. The solution was to store the raw strings the user typed on the Model.

I'm a big fan of creating custom types for units of measure. My earlier implementation had custom Celsius and Farenheit values. However, as part of addressing the two issues above, I now store and pass around strings just about everywhere. In a real project, I'd be looking for opportunities to add them back the moment we added any kind of logic around the numbers.

I made the choice to round all conversions to the nearest tenth to avoid some of the classic IEEE 754 floating point precision issues. Without this, 37ºC converts to 98.60000000000001ºF.

screenshot of temperature converter

Flight Booker

TODO

Timer

TODO

CRUD

TODO

Circle Drawer

TODO

Cells

TODO

License

The repo is provided under the MIT License.