Skip to content

Instantly share code, notes, and snippets.

Daniel Patterson dbp

View GitHub Profile
View printf.hs
c :: String -> ((String -> a) -> a)
c str = \k -> k str
d :: (String -> a) -> Int -> a
d = \k -> (\int -> k (show (int::Int)))
s :: (String -> a) -> String -> a
s = \k -> (\str -> k (str::String))
printf :: ((String -> IO ()) -> a) -> a
View gist:1637897daa92938c45fb
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad
import Data.Monoid
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Database.Rivet
import Database.Rivet.Adaptor.PostgreSQL
dbp / circle.yml
Last active Jun 29, 2017
Haskell project with Stack on CircleCI
View circle.yml
- "~/.stack"
- wget -O /tmp/stack.gz
- gunzip /tmp/stack.gz && chmod +x /tmp/stack
- sudo mv /tmp/stack /usr/bin/stack
- stack setup
- stack build
View gist:3b8bb411cbbe7616ad80
;; -*- mode: emacs-lisp -*- ;;
(require 'cl)
;; set up marmelade for package management
(require 'package)
(add-to-list 'package-archives
'("melpa" . "") t)
View gist:7e9299996b02db2fbfcb
### Keybase proof
I hereby claim:
* I am dbp on github.
* I am dbp ( on keybase.
* I have a public key whose fingerprint is 36EE AD9E A53D 20B7 9C38 3EED 2747 EC48 A98D 4AF0
To claim this, I am signing this object:
View .emacs
;; -*- mode: emacs-lisp -*- ;;
(require 'cl)
;; set up marmelade for package management
(require 'package)
(add-to-list 'package-archives
'("melpa" . "") t)
dbp / gist:6246396
Created Aug 16, 2013
simple discrete scrolling
View gist:6246396
$(function () {
for(var i = 0; i < 10; i++) {
$("#active").append($("<div class='elem'>Block " + i + "</div>"));
$("#pointer").bind("mousedown", start);
function start(event) {
window.startpos = parseInt($("#pointer").css("top"));
$(document).bind("mousemove", drag);
View cookie_sig.ur
dbp / desugar-control.rkt
Created Jan 3, 2013
Desugaring control flow to letCC
View desugar-control.rkt
;; Control flow
;; basically, we provide a shadowed '^throw continuation, and then see what
;; we are handed. if it is an error (ie, an exception), we see if it matches
;; what we are catching, and if it doesn't, we re-throw. Since we are out of
;; scope of the current try/catch, we will now pick up whatever exception
;; continuation is outside. note that this obviously requires the entire program
;; to be wrapped in a try/catch that matches on everything (which it is).
(bdy mat cat els)
dbp / cps.rkt
Created Jan 3, 2013
Python CPS core example
View cps.rkt
#lang plai-typed
(require "python-micro-syntax.rkt"
(define (run-cps [e : UExp])
(UApp (cps e) (UFn '^x (UId '^x)))))
You can’t perform that action at this time.