Skip to content

Instantly share code, notes, and snippets.

View benkolera's full-sized avatar

Ben Kolera benkolera

  • biza.io
  • Brisbane, Australia
View GitHub Profile
crank-docker = nixpkgs.dockerTools.buildImage {
name = "crank-docker";
fromImage = nixpkgs.dockerTools.pullImage {
imageName = "alpine";
imageTag = "3.6";
sha256 = "1sd6p2k3d1dw6apkcj25m5kpkih83jiikgvbzxsqnlfy2y9gyphr";
};
contents = [
crank
nixpkgs.pkgs.cacert
{ nixpkgs ? <nixpkgs> }:
import ./package.nix {
inherit (nixpkgs) stdenv fetchurl makeWrapper jre;
}
# Terminal 1
sos 'hello.hs' -c 'ghcjs hello.hs'
# Terminal 2 in ./hello.jsexe/
node -e <EOF
var connect = require('connect');
var static = require('serve-static');
var server = connect();
@benkolera
benkolera / talk.md
Created October 4, 2016 01:26
Talk?

Thinking with Types - Ben Kolera

A core restriction of functional programming is that functions can only use their inputs to calculate their output and thus must always return the same output for a given input. This has the lovely effect that we can reason about what a function does purely by the the types of their inputs and outputs and use that knowledge when refactoring and composing functional programs.

The types are our key to reducing the possibilities of inputs and outputs of our functions. As we reduce the possibilities and weaken what our function can

# Made with Sonic Pi v2.8
# http://sonic-pi.net
live_loop :bass do
4.times do
sample :bass_hard_c, amp: 2;
sleep 1
2.times do
sample :bass_hit_c, amp: 4;
sleep 0.5
# Sonic Pi track
# http://sonic-pi.net
our_chord = chord(:a5)
base = :a5
live_loop :melody do
with_fx :slicer do
35.times do
play our_chord.choose, attack: 0, release: 0.3, pan: rrand(-1,1), amp: 0.4
class PGHasTimestamp a where
instance PGHasTimestamp PGDate
instance PGHasTimestamp PGTimestamp
instance PGHasTimestamp PGTimestamptz
class PGHasDate a where
instance PGHasDate PGDate
instance PGHasDate PGTimestamp
instance PGHasDate PGTimestamptz
@benkolera
benkolera / paginate.hs
Last active August 31, 2015 07:10
ILY Opaleye
data Pagination = Pagination
{ _paginationPage :: Int
, _paginationWidth :: Int
}
makeLenses ''Pagination
data PaginationResults a = PaginationResults
{ _paginationResultsPage :: Int
, _paginationResultsWidth :: Int
, _paginationResultsMaxPage :: Int64
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.List.NonEmpty (NonEmpty((:|)))
import qualified Data.List.NonEmpty as NEL
import Data.Monoid ((<>))
import qualified Data.Text as T
import Data.Text (Text)
chars :: NonEmpty Char
@benkolera
benkolera / gist:e864c96b39a028f06cc8
Created June 10, 2015 20:39
Overriding ghc-mod and creating non-hackage nixpkgs.
ben at Bens-MacBook-Pro in ~
$ cat ~/.nixpkgs/haskell/ghc-mod.nix
{ mkDerivation, async, base, bytestring, cabal-helper, cereal
, containers, data-default, deepseq, directory, djinn-ghc, doctest
, emacs, fetchgit, filepath, ghc, ghc-paths, ghc-syb-utils
, haskell-src-exts, hlint, hspec, makeWrapper, monad-control
, monad-journal, mtl, old-time, pretty, process, split, stdenv, syb
, temporary, text, time, transformers, transformers-base
}:
mkDerivation {