This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Data.Array (Array, elems, listArray, (!)) | |
import Data.List (elemIndex, uncons, unfoldr) | |
import Data.Maybe (mapMaybe) | |
encodeLehmer :: forall a. (Eq a) => Array Int a -> [a] -> [Int] | |
encodeLehmer set = | |
unfoldr | |
( fmap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env nix-shell | |
#! nix-shell -i bash -p jq dasel | |
jq \ | |
'[.[] | { code: .ddc.code[0], author: .primaryauthor, title: .title }] | sort_by(.code)' \ | |
< $1 | dasel -r json -w csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isDiscriminant = <TypeName extends string, T extends { type: TypeName }>( | |
type: TypeName, | |
candidate: { type: string } | |
): candidate is T => type === candidate.type; | |
type Chunk< | |
TypeName extends string, | |
T extends { type: TypeName } = any & { type: TypeName } | |
> = { | |
type: TypeName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, createElement as h, render, type Element } from "./index.js"; | |
const Counters = () => { | |
const [count, setCount] = useState(0); | |
return h( | |
"div", | |
{ style: "display: flex; flex-direction: column; gap: 1rem" }, | |
h( | |
"div", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- TODO: perhaps better approach is to generate a sequence of days, | |
-- weeks, months and years. Then join them. | |
-- | |
-- TODO: I think I want the 'week of month' to work more like the | |
-- 'recurrence week index', in that it could still respect "real" weeks. I | |
-- think the same questions can be answered that way while being a little | |
-- less surprising (that a string of 7 1s doesn't mean Mon-Sun). | |
CREATE OR REPLACE FUNCTION recurrence_days (start_at timestamp, end_at timestamp, timezone text) | |
RETURNS TABLE ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "set" | |
module ArrayExtras | |
refine Array do | |
def second | |
self[1] | |
end | |
def split_at(i) | |
[first(i), drop(i)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cabal.project.local | |
dist-newstyle | |
*.prof* | |
*.pem | |
*.html* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ExplicitForAll #-} | |
module Combinations (combinations) where | |
import Control.Arrow ((&&&)) | |
import Control.Monad (replicateM) | |
import Control.Monad.State (StateT (StateT), evalStateT) | |
import Data.List (uncons, unfoldr) | |
unconses :: forall a. [a] -> [(a, [a])] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE BlockArguments #-} | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE InstanceSigs #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeFamilies #-} | |
module Main where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE BlockArguments #-} | |
{-# OPTIONS_GHC -Wall #-} | |
-- nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/bed08131cd29a85f19716d9351940bdc34834492.tar.gz -p 'haskellPackages.ghcWithPackages (p: [p.recursion-schemes])' | |
module Main where | |
import Control.Monad.Reader (Reader, asks, local, runReader) | |
import Data.Foldable (traverse_) | |
import Data.Functor.Base (TreeF (NodeF)) |
NewerOlder