Skip to content

Instantly share code, notes, and snippets.


Joël Quenneville JoelQ

  • Thoughtbot
  • Boston
View GitHub Profile
JoelQ / dollar.rb
Last active Aug 9, 2022
Implementing value object semantics as an RSpec shared_example.
View dollar.rb
class Dollar
attr_reader :cents
def initialize(cents:)
@cents = cents
def hash
[self.class, cents].hash
JoelQ /
Created Feb 9, 2018
Refactoring a pipeline of functions in Elm

Refactoring maybe code in Elm

Given this ugly series of cases:

optionalFormattedFriendAddress : Maybe Friend -> Maybe String
optionalFormattedFriendAddress maybeFriend =
    maybeAddress = case maybeFriend of
      Just friend -> Just friend.address
JoelQ /
Last active Jun 14, 2022
Short exercises to learn how generic types and type variables work in Elm.

Generic Elm types exercises

A series of exercises to get a feel for how generic types and type variables work in Elm. For each of these, you are given some code that is not compiling. Your task is to get it compiling. You can change the body of the function but not the signature. No cheating with Debug.todo or infinite recursions either 😉


Server scripts

This is the source for the scripts discussed in

Both scripts are in the bin/ directory of the repo that contains all the markdown documents for blog posts. Users run bin/server and everything is automatically set up for them to view a local preview of the blog. bin/server-setup is a dependency of bin/server and is never run directly by users.

Maitre-d is the name of the "blog engine" discussed in the article.

View month.rb
require "date"
class Month
include Comparable
def self.from_date(date)
self.from_parts(date.year, date.month)
JoelQ /
Last active Mar 12, 2022
Elm Type Glossary

Elm Types Glossary

There's a lot of type terminology and jargon going around when discussing types in Elm. This glossary attempts to list some of the most common type terms along with synonyms, terms from other language communities, examples, and links to more detailed articles on each topic.

JoelQ / tree.rb
Last active Jan 27, 2022
A Ruby implementation of a binary tree and its catamorphism
View tree.rb
class Tree
attr_reader :value, :left, :right
def initialize(value, left, right)
@value = value
@left = left
@right = right
def reduce(initial, &block)
JoelQ /
Last active Dec 5, 2021
What does `x :: xs` pattern matching mean in Elm?

What does x :: xs pattern matching mean in Elm?

:: is the list prepend operator in Elm.

3 :: 2 :: 1 :: []

is equivalent to

JoelQ / RandomToTask.elm
Last active Sep 30, 2021
Turn an Elm random generator into task, allowing it to be chained with other side effects.
View RandomToTask.elm
-- 0.19
randomToTask : Generator a -> Task x a
randomToTask generator =
|> (Tuple.first << Random.step generator << Random.initialSeed << Time.posixToMillis)
-- 0.18
JoelQ /
Last active Jul 28, 2021
List of helpful Ellie's I've written