Skip to content

Instantly share code, notes, and snippets.

@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)
@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 / 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 / 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 / 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 / gcj-2022-r1c-a.hs
Created May 1, 2022 18:03
Google Code Jam 2022 Round 1C Problem A (Haskell)
-- boilerplate elided from gist
docase :: Int -> IO ()
docase i = do
printf "Case #%d: " i
_ <- getLine
ss <- words <$> getLine
outimp putStrLn $ solve ss
aside (x:_,_) = x

The Any Worker Problem

19391D8D-B4ED-4D20-BC30-D12CA5EBC816

In The Manhattan Project (TMP) boardgame, you may use any three of your workers to run this mine.

There are effectively six kinds of workers in TMP, the cross-product of three occupations: Laborers, Engineers, and Scientists, and two types of employment: Full Time Employee (FTE) and Contractor.

@instinctive
instinctive / seoul256.js
Last active September 6, 2021 15:39
Blink shell color theme - seoul256
black = '#4e4e4e';
red = '#d68787'; // red
green = '#5f865f'; // green
yellow = '#d8af5f'; // yellow
blue = '#85add4'; // blue
magenta = '#d7afaf'; // pink
cyan = '#87afaf'; // cyan
white = '#d0d0d0'; // light gray
lightBlack = '#626262'; // medium gray
lightRe
@instinctive
instinctive / recursion-schemes.md
Last active August 4, 2021 17:31
Recursion Scheme Thoughts

Here's an example function to determine whether a set is strongly connected with respect to an adjacency function, implemented with direct recursion:

connected :: Ord a => (a -> [a]) -> Set a -> Bool
connected f s = 
    go (take 1 $ Set.elems s) s
  where
    go _ s | Set.null s = True
    go [] _             = False
@instinctive
instinctive / Chess.md
Created May 12, 2021 03:02
Simple chess protocol

Simple Chess Protocol

Existing chess server protocols (UCI) do a lot of things we don't need. Hence this simpler protocol.

Your chess program will read and write lines of input and output. Informally, the first input line will either be black or white, indicating which side your program will play.