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 com.google.common.base.Optional; | |
public abstract class Validation<E, T> { | |
// avoid subclasses outside of this class | |
private Validation() {} | |
public abstract boolean isSuccess(); | |
public abstract Optional<T> toOptional(); | |
public abstract Validation<T, E> swap(); |
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
libraryDependencies ++= Seq( | |
"org.springframework.data" % "spring-data-mongodb" % "1.7.2.RELEASE", | |
"org.springframework.boot" % "spring-boot-autoconfigure" % "1.2.5.RELEASE" | |
) |
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 Continuation<R, A> extends Function<Function<A, R>, R> { | |
@Override | |
R apply(Function<A, R> f); | |
default <B> Continuation<R, B> map(Function<A, B> f) { | |
return continuation(g -> apply(g.compose(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
package me; | |
import java.util.Collection; | |
import java.util.function.Function; | |
public interface ClassToRefactor_Copy { | |
default void sendMessages(Collection<ParseResult<InputMessage>> parsedMessages) { | |
parsedMessages.stream() | |
.map(parsedMessage -> |
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 org.junit.Test; | |
import java.util.Arrays; | |
import java.util.List; | |
public class GenericsTest { | |
@Test | |
public void should_convert___well_huh() throws Exception { |
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 FunctorModule { | |
trait Functor[F[_]] { | |
def map[A, B](f: A => B): F[A] => F[B] | |
} | |
implicit class ReaderFunctor[E](r: E => _) extends Functor[({ type l[a] = E => a })#l] { | |
override def map[A, B](f: A => B): (E => A) => (E => B) = { r => r andThen 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
private static final Map<String, $CLASS_NAME$> $VAR_CLASS_NAME$sByName = create$CLASS_NAME$sByName(); | |
private final String name; | |
$CLASS_NAME$() { | |
this(null); | |
} | |
$CLASS_NAME$(String name) { | |
this.name = name; |
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
from maybe import Maybe | |
from validation import Validation | |
def Typeclass(): | |
class _Typeclass(object): | |
registered_class = {} | |
@classmethod | |
def instance_for(cls, object_type): |
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 org.junit.Ignore; | |
import org.junit.Test; | |
import java.util.*; | |
public class SortTest { | |
@Test | |
public void testCollectionsSort() { | |
List<Integer> values = getValues(); |
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 scalawebapp | |
import com.sun.net.httpserver.{HttpExchange, HttpHandler, HttpServer} | |
import java.net.InetSocketAddress | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.util.{Failure, Success} | |
class MyHttpServer(port: Int = 8080) { |