Skip to content

Instantly share code, notes, and snippets.

@paulp
paulp / blame-counts.txt
Created February 3, 2014 18:32
Number of lines in src/{library,reflect,compiler,repl} last touched by each person according to git blame.
65138 Paul Phillips
25821 Martin Odersky
19246 Eugene Burmako
15572 Aleksandar Prokopec
10850 Miguel Garcia
9197 Jason Zaugg
7652 Stéphane Micheloud
6952 Iulian Dragos
5807 Adriaan Moors
3367 Den Shabalin
@YoEight
YoEight / process.hs
Created February 9, 2014 18:47
Possible Process Haskell impl.
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE GADTs #-}
module Data.Process where
import Prelude hiding (zipWith)
import Control.Applicative
import Control.Monad
import Data.Foldable
@jessitron
jessitron / gist:9191499
Created February 24, 2014 16:24
StackOverflow in scalaz-stream. My trampoline is not bouncy enough
import scalaz.stream._
import Process._
import scalaz.concurrent.Task
import scala.concurrent.duration._
// git bisect identifies the offending commit as
// https://github.com/scalaz/scalaz-stream/commit/721716ed7af0c126593e9ee227c0f36f21c5b7ed
object Test {
@markhibberd
markhibberd / Example.scala
Created February 27, 2014 18:26
An example of manually encoding and decoding.
import argonaut._, Argonaut._
class Example(val s: String, val i: Int)
object Example {
implicit def ExampleEncodeJson: EncodeJson[Example] =
EncodeJson(example => Json(
"s" := example.s,
"i" := example.i))
object Trampolines {
def odd[A](as: List[A]): TailRec[Boolean] =
as match {
case Nil => Return(false)
case _ :: xs => Suspend(() => even(xs))
}
def even[A](as: List[A]) = as match {
case Nil => Return(true)
case _ :: xs => Suspend(() => odd(xs))
@runarorama
runarorama / gist:9422453
Last active August 29, 2015 13:57
Suggestion for the new representation of `IO` in Scalaz.
import scalaz._
import \/._
import Free._
import scalaz.syntax.monad._
import java.util.concurrent.atomic.AtomicReference
import java.util.concurrent.CountDownLatch
object Experiment {
sealed trait OI[A] {
def map[B](f: A => B): OI[B]
@japgolly
japgolly / Coyo.scala
Created March 12, 2014 07:53
Coyoneda natural transformations
object ForScalaz {
type CoyonedaF[F[_]] = ({type A[α] = Coyoneda[F, α]})
def FG_to_CFG[F[_], G[_] : Functor, A](t: F ~> G): (CoyonedaF[F]#A ~> G) = {
type CF[A] = Coyoneda[F, A]
type CG[A] = Coyoneda[G, A]
val m: (CF ~> CG) = FG_to_CFCG(t)
val n: (CG ~> G) = CF_to_F
val o: (CF ~> G) = n compose m
anonymous
anonymous / F.java
Created March 26, 2014 06:27
import java.util.function.Function;
@FunctionalInterface
public interface F<A, B> extends Function<A, B>{
public default B apply(A a){
try{
return f(a);
}catch(Throwable e){
throw new RuntimeException(e);
}
scala> :paste
// Entering paste mode (ctrl-D to finish)
case class Address(street : String, city : String, postcode : String)
case class Person(name : String, age : Int, address : Address)
// Exiting paste mode, now interpreting.
defined class Address
defined class Person
import scala.language.higherKinds
import scala.math.{pow}
import scalaz._
import Scalaz._
import scalaz.effect._
case class Point(_x : Double, _y : Double)
case class GameUnit(_health : Int, _position : Point)