Skip to content

Instantly share code, notes, and snippets.

@chrisdone
chrisdone / gist:02e165a0004be33734ac2334f215380e
Last active April 16, 2025 07:20
Build and run minimal Linux / Busybox systems in Qemu

Common

export OPT=/opt
export BUILDS=/some/where/mini_linux
mkdir -p $BUILDS

Linux kernel

@chrisdone
chrisdone / typing.md
Last active March 22, 2025 09:05
Typing Haskell in Haskell

Typing Haskell in Haskell

MARK P. JONES

Pacific Software Research Center

Department of Computer Science and Engineering

Oregon Graduate Institute of Science and Technology

@chrisdone
chrisdone / Apple.md
Last active March 1, 2025 02:14
Apple

Sample types:

isDigit :: Monad f => Char -> f Bool
any :: Monad f => (a -> f Bool) -> [a] -> f Bool
reverse :: Monad f => [a] -> f [a]
map :: Monad f => (a -> f b) -> [a] -> f [b]
"hello" :: Monad f => f String
putStrLn :: (MonadIO f) => String -> f ()
show :: (Show a,Monad f) => a -> f String
@chrisdone
chrisdone / example.hs
Created January 20, 2025 16:26
example.hs
*** Exception: Couldn't resolve constraint
<record getter>
due to problem
missing field for field access
arising from record-error.hell:2:24
@chrisdone
chrisdone / trigger-href.js
Created November 27, 2024 10:00
htmx trigger-href extension
// Define the custom HTMX extension
htmx.defineExtension('trigger-href', {
onEvent: function(name, evt) {
// <https://htmx.org/events/#htmx:afterProcessNode>
if (name == 'htmx:afterProcessNode') {
const es = evt.detail.elt.querySelectorAll('a[hx-trigger-href]');
for (const e of es) {
if (typeof e.href == 'string') {
e.addEventListener('click',(e) => {
e.stopPropagation();
@chrisdone
chrisdone / variants.hs
Created November 17, 2024 20:29
variants fragment
--------------------------------------------------------------------------------
-- Variants
-- NB: By the types here, you can't construct a @Variant NilL@.
data Variant xs where
LeftV :: forall k a xs. a -> Variant (ConsL k a xs)
RightV :: Variant xs -> Variant (ConsL k a xs)
-- Construction:
bar :: Variant (ConsL "String" Text (ConsL "Number" Double NilL))
@chrisdone
chrisdone / 1Core.hs
Created January 11, 2017 17:06
Xeno examples
-- RHS size: {terms: 254, types: 135, coercions: 0}
Xeno.$wparse [InlPrag=[0]]
:: GHC.Prim.Addr#
-> GHC.ForeignPtr.ForeignPtrContents
-> GHC.Prim.Int#
-> GHC.Prim.Int#
-> ()
[GblId,
Arity=4,
Str=DmdType <L,U><L,U><L,U><S,U>,
@chrisdone
chrisdone / AnIntro.md
Last active October 29, 2024 15:34
Statically Typed Lisp

Basic unit type:

λ> replTy "()"
() :: ()

Basic functions:

@chrisdone
chrisdone / 0readme.md
Last active October 12, 2024 20:48
GHC JS backend
BUILDKIT_PROGRESS=plain docker image build . -t ghc-javascript:2024-10-10
$ docker run -v`pwd`:`pwd` -w`pwd` --rm ghc-javascript:2024-10-10 ghcjs HelloJS.hs
[1 of 2] Compiling Main             ( HelloJS.hs, HelloJS.o )
[2 of 2] Linking HelloJS.jsexe
@chrisdone
chrisdone / hell-http.hs
Created June 30, 2024 21:17 — forked from chrisdone-artificial/hell-http.hs
hell-http.hs demo
#!/usr/bin/env hell
-- How to run this:
--
-- socat TCP-LISTEN:8081,fork,reuseaddr,max-children=20 EXEC:"./handler.hell"
main = do
line <- Text.getLine
let content =
Text.concat ["<h1>Hello, World!</h1><p>This is generated by Hell.</p><pre>", line, "</pre>"]