This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait CategoryFoldableV[F[_], C[_, _], A] extends FoldableV[F, C[A, A]] { | |
implicit def C: Category[C] | |
//// | |
final def composeRight = sumr(Monoid.liftCategory) | |
} | |
trait ToFoldableV0 { | |
implicit def ToFoldableVUnapply[FA](v: FA)(implicit F0: Unapply[Foldable, FA]) = | |
new FoldableV[F0.M,F0.A] { def self = F0(v); implicit def F: Foldable[F0.M] = F0.TC } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Hoho { | |
trait Foo[A] { | |
def phooey(): Unit | |
} | |
implicit def intFoo(i: Int): Foo[Int] = new Foo[Int] { | |
def phooey(): Unit = println("int " + i.toString) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object AllExamples extends App { | |
import shapeless._ | |
final class All[L <: HList](val values: L) { | |
def apply[A](implicit selector: Selector[L, A]): A = values.select[A] | |
} | |
object All { | |
// package a value of type A, convertible to type B, into an HList containing just B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main (main) where | |
import Control.Monad.RWS | |
import Control.Monad.Writer | |
import Data.Binary.Builder | |
import qualified Data.ByteString.Lazy as Lazy | |
import Data.Hashable | |
import Data.HashMap.Lazy (HashMap) | |
import qualified Data.HashMap.Lazy as Map | |
-- import Data.Map (Map) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mergeconflict.outclass; | |
import static org.objectweb.asm.Opcodes.ACC_PUBLIC; | |
import static org.objectweb.asm.Opcodes.ACC_STATIC; | |
import static org.objectweb.asm.Opcodes.GETSTATIC; | |
import static org.objectweb.asm.Opcodes.RETURN; | |
import static org.objectweb.asm.Opcodes.*; | |
import java.io.FileOutputStream; | |
import java.io.IOException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> implicitly[Bijection[String, Int]] | |
bijection.this.Bijection.identity is not a valid implicit value for com.twitter.bijection.Bijection[String,Int] because: | |
type mismatch; | |
found : com.twitter.bijection.Bijection[Any,Any] | |
required: com.twitter.bijection.Bijection[String,Int] | |
Note: Any >: String, but trait Bijection is invariant in type A. | |
You may wish to define A as -A instead. (SLS 4.5) | |
Note: Any >: Int, but trait Bijection is invariant in type B. | |
You may wish to define B as -B instead. (SLS 4.5) | |
bijection.this.Bijection.identity is not a valid implicit value for com.twitter.bijection.Bijection[Int,String] because: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mergeconflict.collection.concurrent; | |
import java.util.concurrent.Semaphore; | |
import java.util.concurrent.atomic.AtomicReference; | |
import mergeconflict.collection.immutable.Queue; | |
public class BlockingQueue<E> { | |
private final Semaphore s = new Semaphore(0); | |
private final AtomicReference<Queue<E>> q = new AtomicReference<Queue<E>>(Queue.<E> empty()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.function.Function; | |
public interface Bug { | |
static void bug() { | |
bug(a -> a); | |
} | |
static void bug(Function<?, ?> f) {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.function.BiFunction; | |
import java.util.function.Function; | |
import java.util.function.Supplier; | |
/* | |
* Java 8 fantasy land spec: | |
* | |
* A monad is a parameterized data type `M` with the following constraints | |
* - An instance `M<A>` must have a method: `public <B> M<B> bind(Function<A, M<B>> f)` | |
* - `M` must have a static method: `public static <A> M<A> point(A value)` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Inject[-E, +A](inject: E => A) { | |
// covariant functor and monad | |
def map[B](f: A => B): Inject[E, B] = | |
Inject { e => f(inject(e)) } | |
def flatMap[ε <: E, B](f: A => Inject[ε, B]): Inject[ε, B] = | |
Inject { e => f(inject(e)).inject(e) } | |
// to satisfy for-comprehension desugaring in scala < 2.10 | |
def filter(f: A => Boolean): Inject[E, A] = |
OlderNewer