Skip to content

Instantly share code, notes, and snippets.

James Earl Douglas earldouglas

View GitHub Profile
@earldouglas
earldouglas / irc.md
Created Jun 22, 2019 — forked from xero/irc.md
irc cheat sheet
View irc.md

#IRC Reference

Not intended as a guide for newbies, more like a "cheat sheet" for the somewhat experienced IRC user, especially one who wields some power over a channel.

##The Basics

  • /join #channel
    • Joins the specified channel.
  • /part #channel
    • Leaves the specified channel.
View IOEffect.hs
{-# LANGUAGE GADTs #-}
class IOEffect x where
runIOEffect :: x a -> IO a
data M a where
Pure :: a -> M a
Ap :: M (a -> b) -> M a -> M b
Bind :: M a -> (a -> M b) -> M b
M :: IOEffect x => x a -> M a
@earldouglas
earldouglas / _README.md
Last active Oct 3, 2015
APIcon 2014: Real-World Functional Programming
View _README.md

Real-World Functional Programming

May 28, 2014

This code is a companion to the APIcon presentation Real-World Functional Programming by @jearldouglas and @kelleyrobinson. The slides are available here.

In this code, we compare imperative and functional implementations of a withdraw function that might be used in a banking ATM.

Imperative transactions

View Container.scala
trait Container[A] {
def has(a: A): Boolean
}
implicit def listContainer[A](xs: List[A]): Container[A] =
new Container[A] {
override def has(a: A): Boolean = xs.contains(a)
}
View k.scala
// -*- mode: Scala;-*-
// Filename: k.scala
// Authors: lgm
// Creation: Wed Dec 28 14:52:27 2011
// Copyright: Not supplied
// Description:
// ------------------------------------------------------------------------
import scala.collection.mutable.HashMap
import scala.util.continuations._
View BlockingDemo.scala
package await
import java.util.concurrent.Callable
import java.util.concurrent.Executors
object BlockingDemo extends App {
val execSvc = Executors.newSingleThreadExecutor()
val worker = new MeaningOfLife()
@earldouglas
earldouglas / RemoteAkka.scala
Created Mar 20, 2011
Remotely load and register Akka Actor classes at runtime (see https://github.com/JamesEarlDouglas/akka-remote-class-loading)
View RemoteAkka.scala
package com.earldouglas.remoteakka
import akka.actor.Actor
import akka.actor.Actor._
case object Greeting
case class Jar(val bytes: Array[Byte])
case class RegisterRemote(val name: String, val className: String)
object Runner {
You can’t perform that action at this time.