Skip to content

Instantly share code, notes, and snippets.

$$ \tag*{r = f(x)} \cfrac {\Gamma \vdash f: (A) \rightarrow B, x: T, r: R} {(A) \rightarrow B <: (T) \rightarrow R} $$

@andyfriesen
andyfriesen / BUCK
Created July 30, 2023 17:20
Trying to work out how to get a single mega-compilation-database out of Buck. This is a pretty naive approach, but I think it works?
# compdb/BUCK
python_bootstrap_binary(
name = "combine_compdbs",
main = "combine_compdbs.py",
visibility = ["PUBLIC"]
)
<html>
<canvas id="canvas" width="256" height="256" />
<script>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'black';
ctx.fillRect(0, 0, 256, 256);
ctx.fillStyle = 'white';
module Clock = {
include ReactRe.Component.Stateful;
let name = "Clock";
type props = ();
type state = {now: Js_date.t, timerID: option Js_global.intervalId};
let getInitialState () => {
{ now: Js_date.make (), timerID: None };
};
@andyfriesen
andyfriesen / hurbl.md
Created July 12, 2016 00:45
A quick example of why STM is amazing

Say we want to spin off threads every so often, but we also need the ability to wait until they all go away before exiting the application.

In Haskell, we can do this naive thing:

main = do
    count <- newTVarIO 0
    
 let spawnThread action = do
use std::ops::{Add, Sub};
#[derive(Copy, Debug)]
pub struct Rect<T> {
pub left: T,
pub top: T,
pub right: T,
pub bottom: T
}
@andyfriesen
andyfriesen / Main.js
Created April 27, 2015 04:24
Hello World, as produced by Haste
// This object will hold all exports.
var Haste = {};
/* Thunk
Creates a thunk representing the given closure.
If the non-updatable flag is undefined, the thunk is updatable.
*/
function T(f, nu) {
this.f = f;
if(nu === undefined) {
{-# LANGUAGE RecordWildCards #-}
module Promise where
import Control.Monad
import Data.IORef
import Data.Maybe
data Status
= Pending
@andyfriesen
andyfriesen / colourize.sh
Last active August 29, 2015 14:09
Use Pygments to colourize code in the clipboard
#!/bin/bash
set -ex
if [ `uname` == 'Linux' ]; then
PASTE=xclip\ -o
OPEN=xdg-open
else
# Assume OSX
PASTE=pbpaste
@andyfriesen
andyfriesen / irrefutable.hs
Created November 10, 2014 06:20
ghc (7.8.1) accepts this program, even if you specify -Wall -Werror. :(
x :: String
Just (Just (x:[])) = Just (Just [])
main :: IO ()
main = putStrLn x