An Opening Example of Elm: building HTML by parsing parameters

I never enjoyed front-end development, until I found Elm. JavaScript with its `undefined`, its untyped functions, its widely scoped mutable variables. It’s like Play-Doh, it’s so malleable. And when I try to make a sculpture, the arms fall off. It takes a lot of skill to make Play-Doh look good. Then Richard talked me into …

Read moreAn Opening Example of Elm: building HTML by parsing parameters

Quick reference: monads and test.check generators

Combine monads with test.check generators to build them up out of smaller generators with dependencies: (require ‘[clojure.test.check.generators :as gen])(require ‘[clojure.algo.monads :as m])(m/defmonad gen-m   [m-bind gen/bind    m-result gen/return]) (def vector-and-elem  (m/domonad gen-m    [n (gen/choose 1 10)     v (gen/vector gen/int n)     e (gen/element v)]    [v, e])) (gen/sample vector-and-elem);; ([[0 0] 0]     [[0 -1 1 0 -1 0 -1 1] 0]   …

Read moreQuick reference: monads and test.check generators

Left to right, top to bottom

TL;DR – Clojure’s threading macro keeps code in a legible order, and it’s more extensible than methods. When we create methods in classes, we like that we’re grouping operations with related data. It’s a useful organizational scheme. There’s another reason to like methods: they put the code in an order that’s easy to read. In …

Read moreLeft to right, top to bottom

When OO and FP meet: returning the same type

In the left corner, we have Functional Programming. FP says, “Classes shall be immutable!” In the right corner, we have Object-Oriented programming. It says, “Classes shall be extendable!” The battlefield: define a method on the abstract class such that, when you call it, you get the same concrete class back. In Scala.Fight! Here comes the …

Read moreWhen OO and FP meet: returning the same type