Skip to content

Instantly share code, notes, and snippets.

@instinctive
instinctive / fpscala-02-02.md
Last active August 3, 2022 18:38
Functional Programming in Scala: Chapter 2, Exercise 2: isSorted

Functional Programming in Scala: Chapter 2, Exercise 2

Problem Statement

Write isSorted, which checks whether an Array[A] is sorted according to a given comparison function cmp(A,A) => Boolean.

Solution

The comparison function must evaluate to true for successive elements of the array.

@instinctive
instinctive / bus.md
Last active November 25, 2023 17:39
BUS Rules (Splotter Game)

BUS Rules

Setup

  1. Put one of the 15 total passenger meeples on each of the four central intersections. Put 5 (4 if 3 players) time stones in The Clock area, with one of them on the home icon. Give the starting player marker to a randomly determined player.
  2. Each player takes 1 score marker, 20 action markers, and an (unlimited) supply of bus tokens and bus line sticks. Put the score marker on zero, and one bus token in the Bus Depot.
  3. In player order, each player picks two buildings from the supply and places them on any empty "A" location.
  4. In player order, each player places one bus line stick on any street without limitation.
  5. In reverse player order, each player adds one bus line stick using the normal rules for Line Extension.
@instinctive
instinctive / indonesia.md
Last active December 31, 2025 22:39
Indonesia Rules (Splotter game)
documentclass extarticle
fontsize 9pt

Indonesia

  1. Agree whether the amount of money players possess will be open or closed information.
  2. Each player takes a set of wooden markers and 100 rupiah. Place one marker on the first spot of each of the R&D tracks.
  3. Take one marker from each player and place them on the Turn Order track in a random order.
@instinctive
instinctive / add-custom-haskell-packages.md
Created March 7, 2026 18:21
Add custom Haskell packages to default.nix

Adding Custom Haskell Dependencies in Nix

When using developPackage in a default.nix, you may need to depend on Haskell libraries that aren't in nixpkgs — either from a personal GitHub repo or from your local filesystem. Both cases follow the same pattern: override haskellPackages with a custom overrides function and use callCabal2nix to build the package from source.

From a Personal GitHub Repository

Use fetchFromGitHub to pull the source and callCabal2nix to build it:

let
@instinctive
instinctive / unbox.hs
Created March 23, 2026 21:25
Creating custom Unbox types
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}
import qualified Data.Vector.Generic as G
import qualified Data.Vector.Generic.Mutable as M
import qualified Data.Vector.Unboxed as U
import Data.Word (Word64)