Following on from my previous post which highlighted my experience building an Enigma Machine in ClojureScript, I decided it would be interesting to model the machine within Haskell. I felt solving the same problem in this mannor would be a great way to compare and contrast Lisp and heavily-typed languages such as Haskell. Through this process I also wanted to explore using Hspec and QuickCheck for comparable Property-based testing that I achieved in the ClojureScript counterpart.
The Enigma Machine is a typewriter-sized substitution encryption device used by Germany in World War 2. It was so important to the war-time efforts that work carried out by Alan Turing at Bletchley Park to decode the resulting ciphers helped end the war. For years I have been fascinated by this device, and thought it would be interesting to explore implementing a web-based Enigma Machine using ClojureScript. I also thought it would be a great opportunity to explore how I can use Property-based testing to help garner confidence from the resulting implementation.
A couple of years ago I explored using a WebAssembly port of Stockfish (the popular Chess engine) as a ‘Bot’ for a small React-based Chess implementation. I decided over the past week to revisit it and rewrite the implementation in TypeScript, along with providing more Bot types to choosen from.
Recently, I watched an interesting talk about Binary Addition in the TypeScript Type System and thought it would be interesting to explore this concept in more depth. I wanted to pay close attention to how I could leverage the TypeScript type-system to help ensure validity in the final implementation.
The Mystery Calculator is a commonly found Christmas cracker gift, which uses a neat powers of two (binary) addition trick to fool the spectator. I thought it would be interesting to create a small web application in ClojureScript and Reagent, which provided the ability to generate a selection of these cards and perform the trick.