Skip to content

Instantly share code, notes, and snippets.

Brian McKenna puffnfresh

View GitHub Profile
@puffnfresh
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
puffnfresh / sbt.log
Created Jul 15, 2019
ClassBType.info not yet assigned
View sbt.log
java.lang.AssertionError: assertion failed: ClassBType.info not yet assigned: Lcom/atlassian/marketplace/http/rest/v2/
representations/RepresentationFactory$;
at scala.Predef$.assert(Predef.scala:170)
at scala.tools.nsc.backend.jvm.BTypes$ClassBType.info(BTypes.scala:820)
at scala.tools.nsc.backend.jvm.BTypes$ClassBType.isNestedClass(BTypes.scala:883)
at scala.tools.nsc.backend.jvm.BCodeHelpers$BCInnerClassGen$class.toTypeKind(BCodeHelpers.scala:355)
at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.toTypeKind(BCodeSkelBuilder.scala:50)
at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.symInfoTK(BCodeSkelBuilder.scala:82)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.ge
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
puffnfresh / default.nix
Last active Jun 14, 2019
ghc not found patch for haskell.nix
View default.nix
{ pkgs ? import <nixpkgs> {} }:
let
haskell = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) { 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.name}-${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
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/discover-layers)
(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")
View Scott.hs
{-# LANGUAGE ScopedTypeVariables, Rank2Types #-}
module ScottEncoding where
import Prelude hiding (null, length, map, foldl, foldr, take, fst, snd, curry, uncurry, concat, zip, (++))
newtype SMaybe a
= SMaybe { runMaybe :: forall b. b -> (a -> b) -> b }
newtype SList a
= SList { runList :: forall b. b -> (a -> SList a -> b) -> b }
View ghci
Prelude Language.Haskell.TH.Cleanup Generics.Deriving.TH
λ data X = A | B
Prelude Language.Haskell.TH.Cleanup Generics.Deriving.TH
λ putStrLn $(simplifiedTH =<< deriveAll0 ''X)
instance Generic (X :: *)
where type Rep (X :: *) = D1 ('MetaData "X" "Ghci3" "interactive" 'False) (:+: (C1 ('MetaCons "A" 'PrefixI 'False) U1) (C1 ('MetaCons "B" 'PrefixI 'False) U1))
from val_0 = case val_0 of
y_1 -> M1 (case y_1 of
A -> L1 (M1 U1)
B -> R1 (M1 U1))
You can’t perform that action at this time.