Skip to content

Instantly share code, notes, and snippets.

View dbp's full-sized avatar

Daniel Patterson dbp

View GitHub Profile
@dbp
dbp / printf.hs
Created October 13, 2018 19:08
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
{-# 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
dbp / circle.yml
Last active June 29, 2017 09:53
Haskell project with Stack on CircleCI
dependencies:
cache_directories:
- "~/.stack"
pre:
- wget https://github.com/commercialhaskell/stack/releases/download/v0.1.2.0/stack-0.1.2.0-x86_64-linux.gz -O /tmp/stack.gz
- gunzip /tmp/stack.gz && chmod +x /tmp/stack
- sudo mv /tmp/stack /usr/bin/stack
override:
- stack setup
- stack build
;; -*- mode: emacs-lisp -*- ;;
(require 'cl)
;; set up marmelade for package management
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
@dbp
dbp / gist:7e9299996b02db2fbfcb
Created September 17, 2014 23:05
keybase.md
### Keybase proof
I hereby claim:
* I am dbp on github.
* I am dbp (https://keybase.io/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:
;; -*- mode: emacs-lisp -*- ;;
(require 'cl)
;; set up marmelade for package management
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
@dbp
dbp / gist:6246396
Created August 16, 2013 01:11
simple discrete scrolling
$(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);
@dbp
dbp / desugar-control.rkt
Created January 3, 2013 18:29
Desugaring control flow to letCC
;; 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).
[CTry
(bdy mat cat els)
@dbp
dbp / cps.rkt
Created January 3, 2013 18:14
Python CPS core example
#lang plai-typed
(require "python-micro-syntax.rkt"
"python-helpers.rkt")
(define (run-cps [e : UExp])
(begin
(sym-reset)
(UApp (cps e) (UFn '^x (UId '^x)))))