Skip to content

Instantly share code, notes, and snippets.

View chandler-barlow's full-sized avatar
👽
Playing Dark Souls

Chandler Barlow chandler-barlow

👽
Playing Dark Souls
View GitHub Profile
{ pkgs, makeWrapper, stdenv, lib, ... }:
let
janet = stdenv.mkDerivation {
name = "spork";
src = builtins.fetchGit {
url = "https://github.com/janet-lang/janet";
};
postPatch =
''
substituteInPlace janet.1 \
(math/seedrandom (os/cryptorand 8))
(defn rng [upper lower]
(math/round (+ lower (* upper (math/random)))))
(defn random-nth [arr]
(rng (- (length arr) 1) 0))
(defn split? [money]
(and (> money 0) (= (% money 10) 0)))
@chandler-barlow
chandler-barlow / haskellShell.nix
Last active August 4, 2025 18:05
Nix shell for a haskell project
{ pkgs ? import <nixpkgs> {} }:
pkgs.haskellPackages.developPackage {
root = ./.;
withHoogle = true;
modifier = drv:
pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages;
[ cabal-install
ghc
haskell-language-server
]);
@chandler-barlow
chandler-barlow / typereps.hs
Last active March 5, 2025 19:11
List of type reps from a type level list
{-# LANGUAGE DataKinds #-}
import qualified Data.Typeable as T
import qualified GHC.Fingerprint as F
import qualified Data.Proxy as P
hashAll :: T.Typeable a => P.Proxy a -> [F.Fingerprint]
hashAll =
let typeReps = collect . T.typeRep
collect :: T.TypeRep -> [T.TypeRep]
const formatDate = d => ( d => `${d[1]} ${d[0]} ${d[2]}` )(new Date(d).toDateString().slice(4).split(' '));