Skip to content

Instantly share code, notes, and snippets.

View derekjw's full-sized avatar

Derek Williams derekjw

  • FP Solutions Ltd
  • London, United Kingdom
View GitHub Profile
import annotation.unchecked.uncheckedVariance
import reflect.runtime.universe.TypeTag
package object stuff {
// required for the better ??? operator
type MyTypeTag[+A] = TypeTag[A @uncheckedVariance]
def ???[A](implicit tag: MyTypeTag[A]): A =
throw new NotImplementedError(s"unimplemented value of type ${tag.tpe}")
}
package com.codecommit.misc
import scalaz._
import scalaz.concurrent.Task
import scalaz.iteratee._
import scalaz.stream._
object conversion {
// TODO generalize to EmitterT
@viktorklang
viktorklang / in-fino-veritas.zsh-theme
Last active July 31, 2023 01:47
In Fino Veritas ZSH theme
#!/usr/bin/env zsh
# in fino veritas
# Borrowing shamelessly from these oh-my-zsh themes:
# fino-time
# pure
# https://gist.github.com/smileart/3750104
# Set required options
/**
* "Select" off the first future to be satisfied. Return this as a
* result, with the remainder of the Futures as a sequence.
*
* @param fs a scala.collection.Seq
*/
def select[A](fs: Seq[Future[A]])(implicit ec: ExecutionContext): Future[(Try[A], Seq[Future[A]])] = {
@tailrec
def stripe(p: Promise[(Try[A], Seq[Future[A]])],
heads: Seq[Future[A]],
@ymasory
ymasory / scala-irc
Last active August 30, 2017 21:16
List of all Scala-related IRC channels.
Please help compile a list of all Scala-related IRC rooms.
All of these channels are on Freenode.
#akka | concurrency & distribution framework
#argonaut | json library
#fp-in-scala | the book Functional Programming in Scala
#geotrellis | geoprocessing library
#indyscala | regional scala group
#json4s | json library
@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]
@bjornharrtell
bjornharrtell / proguard.cfg
Created August 9, 2012 20:58
Proguard config for akka including akka remote (tested with akka 2.0.2)
-dontwarn org.jboss.netty.logging.**
-dontwarn org.osgi.**
-dontwarn javax.servlet.**
-dontwarn org.jboss.netty.channel.socket.http.**
## Unsafe is there at runtime
-dontwarn sun.misc.Unsafe
-keep class sun.misc.Unsafe{
*;
}
@retronym
retronym / unimplicitly.scala
Created April 20, 2012 20:59
unimplicitly
scala> import scala.language.experimental.macros
import scala.language.experimental.macros
scala> def unimplicitlyImpl[A: c.TypeTag](c: reflect.makro.Context) = {
| val A = implicitly[c.TypeTag[A]].tpe
| val i = c.inferImplicitValue(A, silent = true)
| if (i == c.mirror.EmptyTree) c.reify(())
| else sys.error("unexpected implicit of type %s: %s".format(A, i))
| }
unimplicitlyImpl: [A](c: scala.reflect.makro.Context)(implicit evidence$1: c.TypeTag[A])c.mirror.Expr[Unit]
@paulp
paulp / .gitconfig
Created December 1, 2011 00:12
my gitconfig
[user]
name = Paul Phillips
email = paulp@improving.org
[github]
user = $GITHUB_USER
token = $GITHUB_TOKEN
[clean]
requireForce = false
[grep]
lineNumber = true
@debasishg
debasishg / gist:1168340
Created August 24, 2011 15:42
Encoding of List using rank-3 types (Runar's code from http://paste.pocoo.org/show/463632/)
import scalaz._
import Scalaz._
type List[A] = Forall[({type f[B] = ((A, B) => B, B) => B})#f]
val nil: Forall[List] = new Forall[List] {
def apply[A] = new List[A] {
def apply[B] = (c, n) => n
}
}