Skip to content

Instantly share code, notes, and snippets.

View jroesch's full-sized avatar

Jared Roesch jroesch

View GitHub Profile
@simonmichael
simonmichael / gist:1185421
Created September 1, 2011 03:59
ghc-pkg-clean, ghc-pkg-reset
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages.
# ghc-pkg-clean -f cabal/dev/packages*.conf also works.
function ghc-pkg-clean() {
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'`
do
echo unregistering $p; ghc-pkg $* unregister $p
done
}
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place.
@retronym
retronym / SI-3346.scala
Created November 6, 2011 15:11
SI-3346
//
// An attempt to workaround SI-2712, foiled by SI-3346
//
trait TC[M[_]]
type EitherInt[A] = Either[Int, A]
implicit object EitherTC extends TC[EitherInt]
object Poc2 {
trait TARInt
trait Basket[A,B] {
def iAmABasket = {}
}
trait BasketFactory[A,B] {
def create(v: A): Basket[A,B]
@viktorklang
viktorklang / minscalaactors.scala
Last active March 25, 2024 19:01
Minimalist Scala Actors
/*
Copyright 2012-2021 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@fogus
fogus / multimethod.rb
Created August 11, 2012 13:28 — forked from alandipert/multimethod.rb
Multimethods in Ruby
class Multimethod
attr_accessor :dispatch, :methods, :heirarchy, :default_method
class NoMatchingMethodError < StandardError
end
def initialize(&dispatch)
@dispatch = dispatch
@methods = []
@heirarchy = {}
end
@etorreborre
etorreborre / gist:3870064
Created October 11, 2012 03:54
Unboxed union types with a context bound
/**
* this is an experiment to create unboxed union types with a phantom type and a context bound.
* All the good ideas come from @milessabin post, comments and links: http://www.chuusai.com/2011/06/09/scala-union-types-curry-howard/#comment-22
*/
/** trait for anything that can be A or B */
trait Or[A, B] {
// a phantom type, there will be no instance of this type that we'll use
type l[T]
// an alias for l[t]
@dherman
dherman / ssa-cps-anf.txt
Created November 20, 2012 03:10
links on SSA, CPS, and A-normal form
Original paper on A-normal form:
http://redlinernotes.com/docs/Classics/The%20Essence%20of%20Compiling%20with%20Continuations.pdf
A high-level intro to ANF:
http://matt.might.net/articles/a-normalization/
One of the earlier attempts to relate SSA and CPS:
@jdegoes
jdegoes / DataScienceInScala.scala
Created February 8, 2013 15:11
Example code for the Creating a Data Science Platform in Scala talk.
object BenchmarkCommon {
import scala.util.Random
val DatasetSize = 10000
val Iterations = 10000
val ArrayPoolSize = 1000
val ArrayPool = {
def randomArray(): Array[Int] = {
val array = new Array[Int](DatasetSize)
@milessabin
milessabin / gist:4973961
Last active December 13, 2015 20:58
Lazy pattern matching in Scala made even lazier with scalaz's Need.
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_05).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import scalaz._
import scalaz._
scala> val (foo, bar, baz) = (Need({println("foo") ; "foo"}), Need({ println("bar") ; "bar"}), Need({ println("baz") ; "baz"}))
foo: scalaz.Need[java.lang.String] = scalaz.Need$$anon$4@1d90d034
bar: scalaz.Need[java.lang.String] = scalaz.Need$$anon$4@e551516
import Data.Foldable
import Data.Monoid
pipeline :: [a -> a] -> a -> a
pipeline = appEndo . getDual . foldMap (Dual . Endo)
main = print $ pipeline [(+1), (*10)] 100