Skip to content

Instantly share code, notes, and snippets.

@nlinker
nlinker / gist:45b33c2584f9cb6ddd7b072878aa412a
Created May 13, 2016 22:46 — forked from pcapriotti/gist:1761136
Composition of free monads
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
import Control.Monad
import Control.Monad.Free
class (Functor f, Functor g, Functor h) => Compose f g h | f g -> h where
compose :: f x -> g y -> Free h (Free f x, Free g y)
compose f g = return (liftF f, liftF g)
composeF :: Compose f g h => Free f x -> Free g x -> Free h x
trait Module {
type shape
}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Lens -- lens
import Control.Monad.IO.Class -- transformers
import Control.Monad.Trans.AWS -- amazonka
import Network.AWS.EC2 -- amazonka-ec2
main :: IO ()
@nlinker
nlinker / RedBlackTree.hs
Created October 16, 2015 11:37 — forked from rampion/RedBlackTree.hs
red-black trees in haskell, using GADTs and Zippers
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
module RedBlackTree where
data Zero
data Succ n
type One = Succ Zero
data Black
@nlinker
nlinker / example.sh
Last active August 29, 2015 14:26 — forked from tristanbes/example.sh
Install Graphite on Debian Server
# Installing graphite dependencies
apt-get install -y python2.6 python-pip python-cairo python-django python-django-tagging
apt-get install -y libapache2-mod-wsgi python-twisted python-memcache python-pysqlite2 python-simplejson
pip install whisper
pip install carbon
pip install graphite-web
# Setup a vhost by grabbing the example the graphite team released on their repo.
# In this file, you'll provide the url used to access to your Graphite dashboard
wget https://raw.github.com/tmm1/graphite/master/examples/example-graphite-vhost.conf -O /etc/apache2/sites-available/graphite
@nlinker
nlinker / install-ghc.md
Last active August 29, 2015 14:25 — forked from yantonov/install-ghc-ubuntu.md
how to install latest GHC 7.10.1 + cabal 1.22.3.0 from source on ubuntu

How to install latest GHC 7.10.1 + cabal 1.22.3.0 from source on ubuntu

for your convinience these instuction is available as:
gist
git repo

ghc

ubuntu prerequisites

import scala.language.implicitConversions
/**
* @author gwenzek
*
*/
class ArgsOps(ops: Map[String, OptionalParam], val args: Array[String]){
def apply(op: String) = ops(op)
}
trait Isomorphism[A, B] {
def fw: A => B
def bw: B => A
}
object Isomorphism {
implicit def anyIso[A](a: A) = new {
def as[B](implicit ev: Isomorphism[A, B]) = ev fw a
}
#![feature(phase)]
#[phase(plugin, link)] extern crate log;
extern crate green;
extern crate rustuv;
use std::io;
use std::os;
use std::io::{Listener,Acceptor,TcpStream};
#[start]
/*
* OpenSimplex (Simplectic) Noise in Java.
* (v1.0.1 With new gradient set and corresponding normalization factor, 9/19/14)
*/
public class OpenSimplexNoise {
private static final double STRETCH_CONSTANT_3D = -1.0 / 6;
private static final double SQUISH_CONSTANT_3D = 1.0 / 3;