scala
Talking about laws for the REA FP guild
In July 2020 I gave a presentation at the functional programming guild for my employer REA Group. The talk involved slowly building a type class hierarchy extending from semigroup. Each additional step added the laws required by the child type class.
Defining an Ordering for java.time.Period
I’ve written a library called intime
, which provides exhaustive integration
between the classes in the java.time
library and some common Scala libraries. The most interesting problem I encountered was defining an Ordering
(or an Order
for Cats) for the java.time.Period
class. Because months and years cannot simply be expressed as a number of days, This post will discuss those issues.
InvariantK
In my previous post, I discussed using Invariant
to
add behaviour to value classes. Unfortunately, Invariant
is not powerful enough to provide instances for higher-kinded
type classes like Functor
or Traverse
. In this post, I’ll introduce InvariantK
, a type class I’ve written to solve
this limitation.
Type class instances for value classes with Invariant
Previously I discussed about the advantages of wrapping common types like
Int
or String
in a value class. This allows us to encode more semantic meaning into our types, and means we can use
the compiler to check for a number of bugs. In this post I’ll discuss how we can use the Invariant
type class to
selectively surface functionality from the underlying type for our value class.
Value classes
One of the most valuable techniques I’ve learned from strongly-typed functional programming is value classes. By wrapping common types in specialised case classes, we can improve semantic clarity and leverage compile-time checks to avoid bugs.
functional-programming
Talking about laws for the REA FP guild
In July 2020 I gave a presentation at the functional programming guild for my employer REA Group. The talk involved slowly building a type class hierarchy extending from semigroup. Each additional step added the laws required by the child type class.
Defining an Ordering for java.time.Period
I’ve written a library called intime
, which provides exhaustive integration
between the classes in the java.time
library and some common Scala libraries. The most interesting problem I encountered was defining an Ordering
(or an Order
for Cats) for the java.time.Period
class. Because months and years cannot simply be expressed as a number of days, This post will discuss those issues.
InvariantK
In my previous post, I discussed using Invariant
to
add behaviour to value classes. Unfortunately, Invariant
is not powerful enough to provide instances for higher-kinded
type classes like Functor
or Traverse
. In this post, I’ll introduce InvariantK
, a type class I’ve written to solve
this limitation.
Type class instances for value classes with Invariant
Previously I discussed about the advantages of wrapping common types like
Int
or String
in a value class. This allows us to encode more semantic meaning into our types, and means we can use
the compiler to check for a number of bugs. In this post I’ll discuss how we can use the Invariant
type class to
selectively surface functionality from the underlying type for our value class.
Value classes
One of the most valuable techniques I’ve learned from strongly-typed functional programming is value classes. By wrapping common types in specialised case classes, we can improve semantic clarity and leverage compile-time checks to avoid bugs.
video-games
The Animal Crossing museum
I’ve been playing Animal Crossing: New Horizons with my 3-year-old recently, and the museum’s fossil section has really resonated with me. It’s come at a time when I’m indulging a fascination with evolutionary history (through David Attenborough docos and Wikipedia). In this post I’m going to try to capture what I like so much about it. It’s just a wonderful piece of storytelling.
Celeste
I’m not a particularly eclectic gamer. Until about 2017 I played a lot of Dota 2. Before that it was Starcraft 2 and Starcraft. There are a few franchises where I’ll generally pick up a new release, particulary Zelda. About 2 years ago I picked up Celeste, and it’s been my main game since. I feel like my time with Celeste is coming to a close, so I wanted to put together some reflections on this magnificent game.
Revisiting Link’s Awakening
Late last year, Nintendo released a remake of The Legend of Zelda: Link’s Awakening for the Switch. I only got a few days of gameplay out of it at the time. Over the last week, in an attempt to find some reprieve during Melbourne’s grinding COVID lockdowns, I sat down and re-played the game from the beginning, all the way to 100% completion (all heart pieces, seashells and trophies).
book-reviews
The Blazing World and The Blazing World
My first completed book of the year was The Blazing World: A New History of Revolutionary England, 1603-1689 by Jonathan Healey. I found it a well-balanced presentation of the kind of historical period I find really fascinating. It is unapologetically narrative history, but I didn’t find it too detailed. Through anecdotes and what data is available, it manages to emphasise (if not quite centre) the experiences of regular men and women in a way that stops it from being entirely a “great men of history” book.
Books I read in 2023
I read 13 books in 2023, the most I’ve managed in one year since I was at university. Through the year I’ve been writing notes and small reviews on some of the things I’ve read, and I’ve decided to collect them here.
Reflections on Reflections
Over the last week I have continued my “making up for a lack of a humanities education” reading and got through Reflections on the Revolution in France by Edmund Burke. It’s structurally unfamiliar, not a book but really a 280-page letter. It lacks chapters or section headings and is conversational and good-natured (at least regarding its recipient), which I think made it a relatively easy read.
australian-politics
Comparing the Australian population and electorate by birthplace
Last week Anthony Albanese floated the idea of granting New Zealand residents in Australia voting rights before they had received Australian citizenship. Following on from a previous post, I decided to take a look at data from the 2016 census to get a sense of how Australia’s electorate differs from its population when we consider someone’s country of birth. My finding is that NZ-born Australians are the most disenfranchised group in Australia, when looking based on country-of-birth.
Comparing the Australian population and electorate by age
A couple of weeks ago there were a few points made on Twitter about the extent to which Australia’s parliament reflects the diversity of Australia’s population. I thought it might be interesting to iterate on that question a bit, and do some poking around about the extent to which the Australian electorate is representative of its population. Further to that, I wonder whether our parliament is more reflective of the electorate than the population.
random
Thinking about mortality and AstraZeneca
Recently I received my first dose of the Oxford-AstraZeneca vaccine. Particularly in Australia there’s been a lot of discussion about the risks of taking this vaccine. I did a bit of thinking about these risks in my own way, and I thought it might be useful for posterity to write out the structure of my thinking.