Skip to content

Instantly share code, notes, and snippets.

View chrisdone-artificial's full-sized avatar

Chris Done chrisdone-artificial

View GitHub Profile
@chrisdone-artificial
chrisdone-artificial / fp.yaml
Last active November 7, 2025 13:37
Functional Pearls weekly discussion job
name: Create Functional Pearl discussion weekly
on:
schedule:
- cron: "0 12 * * 5" # 5 = Friday (12:00 UTC)
workflow_dispatch:
jobs:
create-discussion:
runs-on: ubuntu-latest
@chrisdone-artificial
chrisdone-artificial / 0readme.md
Last active November 7, 2025 09:49
Nondeterminism with Referential Transparency in Functional Programming Languages

The one using a proper PRNG is more typical.

The other one is more like the paper intended, I think, which is to literally run a side-effect on every call to choice (lazy I/O), which is what this does (modulo buffered reads).

data Opts = Opts {
startDate :: Text,
step :: Text
}
options =
(\startDate step -> Main.Opts { startDate, step })
<$> Options.strOption (Option.long "start-date" <> Option.help "Starting date in 2025-01-24 format.")
<*> Options.strOption (Option.long "step" <> Option.help "How many days to add each line.")
@chrisdone-artificial
chrisdone-artificial / background.js
Last active October 10, 2025 13:11
temp-link-opener
// Create the context menu item when the extension is installed
browser.contextMenus.create({
id: "open-link-temporarily",
title: "Open Link temporarily",
contexts: ["link"]
});
// Track tabs that should be auto-closed
const tempTabs = new Map();
newtype T1 t a = T1 { unT1 :: forall e. t e a }
deriving instance (forall e. Functor (t e)) => Functor (T1 t)
instance (forall e. Applicative (Either e)) => Applicative (T1 Either) where
pure x = T1 (pure x)
(<*>) f x = T1 (unT1 f <*> unT1 x)
instance (forall e. Monad (Either e)) => Monad (T1 Either) where
(>>=) m f = T1 (unT1 m >>= unT1 . f)
newtype L c t = L (forall e. Dict (c (t e)))
withL :: forall c t r. L c t -> (forall e. Dict (c (t e)) -> r) -> r
withL (L dict) r = r dict
functorEitherL :: L Functor Either
functorEitherL = L Dict
someFuntorEitherL :: Dynamic
someFuntorEitherL = toDyn functorEitherL
@chrisdone-artificial
chrisdone-artificial / summaries.
Created September 25, 2025 14:21
Llama-3.2-3B-Instruct-uncensored.Q4_K_M summarise per-paragraph vs whole thing
Llama-3.2-3B-Instruct-uncensored.Q4_K_M
summarise: https://chrisdone.com/posts/llms/
> llama-summarise-buffer:
The document is a personal reflection by the author, a researcher, on their experiences with large language models (LLMs)
from September 23, 2025, discussing their applications, limitations, and concerns regarding their impact.
> summarise whole thing:
@chrisdone-artificial
chrisdone-artificial / laws.md
Last active September 23, 2025 20:17
laws

Law's that apply to our industry (and others) are interesting to me, and I'm writing up here the ones that often come to mind. I usually forget the name, so writing them up might be helpful for remembering in future.

Parkinson's law

C. Northcote Parkinson's law: Work expands so as to fill the time available for its completion. Similarly, in computing, data expands to fill the space available for storage,

@chrisdone-artificial
chrisdone-artificial / wired applicative constrained normal.hs
Created August 26, 2025 13:43
wired applicative constrained normal
{-# language KindSignatures, RankNTypes, GADTs, LambdaCase, GeneralizedNewtypeDeriving #-}
import Data.Functor.Const
import Control.Monad.ConstrainedNormal
import qualified Data.ByteString as S
import qualified Data.ByteString.Char8 as S8
import Data.Functor.Identity
import Data.ByteString (ByteString)
import qualified Data.Map as Map
import Data.Map (Map)
import qualified Data.Set as Set
@chrisdone-artificial
chrisdone-artificial / free monad version applicative wired monad.hs
Last active August 25, 2025 12:26
free monad version applicative wired monad.hs
{-# LANGUAGE KindSignatures #-}
{-# language GADTs, LambdaCase, GeneralizedNewtypeDeriving #-}
import Control.Monad.Free
import Control.Applicative.Free
import qualified Data.ByteString as S
import qualified Data.ByteString.Char8 as S8
import Data.Functor.Identity
import Data.ByteString (ByteString)
import qualified Data.Map as Map
import Data.Map (Map)