# Using phantom types to associate static values and generic types

Phantom types seem to get used reasonably regularly in a variety of languages for ensuring the safe use of various values (as identifiers, for state transitions and others).

A colleague and I recently found a case where they provided a slightly different benefit. They still helped provide some required type safety, but in this case they also helped to statically associate a value with a generic type parameter, avoiding a runtime lookup and keeping the code succinct using type inference.

This post uses Kotlin, but should be applicable to Java or any other language with generics / parameterised types.

# Quick, hacky truth tables in Haskell

Today I wanted to test a few boolean expressions, and ended up with some quick truth table generation hackery in Haskell which I thought I’d note down for next time. I’m sure there are many better ways of doing this, but this way was mine.

# For sale: Several tonnes of yak hair, going cheap

A sordid tale of builds, Gradle, Grunt, node, yarn, Linux, TeamCity, Docker, ssh, and shaven yaks.

# StandaloneDeriving to fix forgetfulness in GHCi

Quick reminder to Future Dave, as I’m going to assume he’ll keep making the same mistake Past and Present Daves make.

When switching between my editor and GHCi REPL to test stuff out I often forget to add a deriving (Show, Eq) or similar line to my data types. This normally occurs after I’ve just set up a bit of test data in the REPL, so if I just fix the data declaration and :reload GHCi then my setup will be lost. We can use the StandaloneDeriving GHC extension to help here.

# Aggregation

Today I wanted to look at an approach for producing aggregate data from multiple measurements over a source. I’m learning Kotlin at the moment so I’ll use that for the examples in this post, but we can apply the same idea to pretty much any language (I’ve used similar approaches in F#, and it would work with C# albeit with a bit more code noise).

# Pondering a prescription for pattern matching prevalance

In which I ramble on about how my thoughts on pattern matching have changed over the years.

# Currying vs. partial application

When I first came across the terms “currying” and “partial application” I was a bit confused about the difference. Here is my attempt at an explanation1. I’m not 100% confident of my understanding, so please point out any inconsistencies – I’m happy to be corrected :).