Property-based testing of higher-order functions

Property-based testing and functional programming are friends, because they’re both motivated by Reasoning About Code. Functional programming is about keeping your functions data-in, data-out so that you can reason about them. Property-based testing is about expressing the conclusions of that reasoning as properties, then showing that they’re (probably) true by testing them with hundreds of … Read moreProperty-based testing of higher-order functions

JVM Threads, ???, and Open Source

Lately, open source is important to me. Today, for instance: it starts with a useful library, complicated by Java threading, confused by a Scala language feature, and ends with happiness and joy because Open Source. I’m using scalaz.concurrent.Task, a monad (LINK) with at least three special powers. First, it use a Future internally, which perform … Read moreJVM Threads, ???, and Open Source

Trains within trains

In Java, there are primitive types and there are objects. Often we want to work with everything as an object, so those primitives get boxed up into object wrappers.Ruby and Scala say, “That’s silly. Let everything be an object to begin with.” That keeps parameter-passing semantics and comparison and printing operations consistent. Yesterday while writing … Read moreTrains within trains

Data Exposure and Encapsulation

TL;DR – Scala lets you expose internal data, then later change underpinnings while maintaining the same interface. The functional Way is an open Way. Internal data is available to anyone who wishes to extract it. “But what about encapsulation??” – horrified OO programmer“We do not fear your code, for you cannot screw up our immutable … Read moreData Exposure and Encapsulation

Idempotence in math and computing

“Idempotent” is a big word. It’s one of the four-dollar words thrown around by functional programmers, and it confuses people — including functional programmers. This is because we don’t use it consistently. In math, idempotence describes only unary functions that you can call on their own output. Math-idempotence is, “If you take the absolute value … Read moreIdempotence in math and computing