Skip to content

Instantly share code, notes, and snippets.

puffnfresh /
Last active Apr 27, 2021
Writing functions once, using Cubix., and FP.js are generated by running Main.hs
public class FP
public static <A> A identity (A a)
return a;
public static <A, B> A constant (A a, B b)
return a;
puffnfresh / lua-launchdarkly.c
Last active Jul 13, 2020
Binding LaunchDarkly C SDK to Lua
View lua-launchdarkly.c
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <launchdarkly/api.h>
#include <openssl/sha.h>
#include <lua.h>
puffnfresh / not.fgg
Last active Jun 17, 2020
Encoding Booleans in Featherweight Generic Go
View not.fgg
package main;
type Any(type) interface { };
type Name(type a Any()) interface {
value(type)() a
type Value(type a Any()) struct {
value a
View agda-blocks.hs
#!/usr/bin/env nix-shell
#!nix-shell -p "haskellPackages.ghcWithPackages (p: [ p.pandoc p.pandoc-types ])" -i runhaskell
{-# LANGUAGE OverloadedStrings #-}
import Text.Pandoc.JSON
import Text.Pandoc.Shared (tshow)
import Data.Text as T
main :: IO ()
puffnfresh / sbt.log
Created Jul 15, 2019 not yet assigned
View sbt.log
java.lang.AssertionError: assertion failed: not yet assigned: Lcom/atlassian/marketplace/http/rest/v2/
at scala.Predef$.assert(Predef.scala:170)
View doom2nix.el
#!/usr/bin/env nix-shell
#! nix-shell -i "emacs --batch -l $HOME/.emacs.d/core/core.el -l $HOME/.emacs.d/core/core-packages.el -l $HOME/.emacs.d/core/autoload/packages.el -l" -p "emacsWithPackages (p: [ p.persistent-soft p.use-package p.quelpa p.async ])"
;; doom-module-load-path
(princ "p:\n")
(princ "let checked = n:\n")
(princ " let p' = p.${n} or null;\n")
(princ " in if p'.meta.broken or false then null else p';\n")
(princ "in\n")
puffnfresh / default.nix
Last active Jun 14, 2019
ghc not found patch for haskell.nix
View default.nix
{ pkgs ? import <nixpkgs> {} }:
haskell = import (builtins.fetchTarball { inherit pkgs; };
happyHack = config:
let inherit (config.hsPkgs) happy;
in "export happy_datadir=${happy.components.exes.happy}/share/${builtins.currentSystem}-ghc-${config.compiler.version}/${}-${happy.identifier.version}";
pkgSet = haskell.mkCabalProjectPkgSet {
View LoadedData.ts
type LoadedData<A> =
<B>(f: (a: A) => B, g: (e: Error) => B, b: B) => B;
function loaded<A>(a: A): LoadedData<A> {
return <B>(f: (a: A) => B, error: (e: Error) => B, empty: B) => f(a);
function error<A>(e: Error): LoadedData<A> {
return <B>(success: (a: A) => B, f: (e: Error) => B, empty: B) => f(e);
puffnfresh / Payments.hs
Created Mar 12, 2019 — forked from friedbrice/Payments.hs
Java6-compatible algebraic data types via Church-Scott Encoding
View Payments.hs
module Payments where
data Customer = Customer { name :: String, age :: Int } deriving (Eq, Ord, Show)
-- I know partial record fields is an anti-pattern, but who's counting?
data Payment
= Cash { customer :: Customer, amount :: Double }
| Credit { customer :: Customer, amount :: Double, cardNumber :: Int }
| Check { customer :: Customer, amount :: Double, routingNumber :: Int, accountNumber :: Int }
deriving (Eq, Ord, Show)
View spacemacs2nix.el
#!/usr/bin/env nix-shell
#! nix-shell -i "emacs --batch -l $HOME/.emacs.d/core/core-load-paths.el -l" -p emacs26-nox
(require 'core-configuration-layer)
(configuration-layer/make-all-packages nil)
(princ "p:\n")
(princ "let checked = n:\n")
(princ " let p' = p.${n} or null;\n")
(princ " in if p'.meta.broken or false then null else p';\n")