This file contains hidden or 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> def f[A[_] <: Seq[_]](f: A[Int]) = f.head | |
| f: [A[_] <: Seq[_]](f: A[Int])A | |
| scala> def f[A[_] <: Seq[t] forSome { type t }](f: A[Int]) = f.head | |
| f: [A[_] <: Seq[_]](f: A[Int])A | |
| scala> def f[A[t] <: Seq[_] forSome { type t}](f: A[Int]) = f.head | |
| f: [A[t] <: Seq[_] forSome { type t }](f: A[Int])A |
This file contains hidden or 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 ApplicativeMagic[F[_]] { | |
| def apply[C](f: ApplicativeMagicFunctionHolder[FunctionArg => C]): F[C] | |
| type FunctionArg | |
| } | |
| class ApplicativeMagicFunctionHolder[F](val f: F) | |
| object ApplicativeMagicFunctionHolder { | |
| implicit def fix2[A,B,C](f: (A,B) => C): ApplicativeMagicFunctionHolder[Tuple2[A,B] => C] = | |
| new ApplicativeMagicFunctionHolder({ case (a,b) => f(a,b) }) | |
| implicit def fix3[A,B,C,D](f: (A,B,C) => D): ApplicativeMagicFunctionHolder[Tuple2[Tuple2[A,B],C] => D] = | |
| new ApplicativeMagicFunctionHolder({ case ((a,b),c) => f(a,b,c) }) |
This file contains hidden or 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
| // Is this even faintly novel? The closest I've seen is | |
| // | |
| // http://stackoverflow.com/questions/2618891/using-lazy-evaluation-functions-in-varargs | |
| // | |
| // which is a bit clunky by comparison. But this is so trivial someone must have | |
| // done it this way before. | |
| // UPDATE: | |
| // Thanks to the Twittersphere (@etorreborre, @pchiusano and @loverdos) for a few sightings of related things, | |
| // |
This file contains hidden or 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
| // see https://github.com/gseitz/Lensed | |
| object Lensed { | |
| import scalaz._ | |
| import Scalaz._ | |
| case class Address(street: String, number: Int) | |
| case class Person(name: String, address: Address) |
This file contains hidden or 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
| /* | |
| This is implemented following the instructions in "The Design and Analysis of | |
| Computer Algorithms, AHO Hopcroft Ullman, 1974". | |
| The implementation uses a DFS to find the strongly connected components (SCCs) | |
| of a graph. During the DFS the vertices are placed on a stack in the order | |
| they are visited. Whenever a root is found, all vertices of the corresponding | |
| SSC are on the top of the stack and are popped. |
This file contains hidden or 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
| /* | |
| This is implemented following the instructions in "The Design and Analysis of | |
| Computer Algorithms, AHO Hopcroft Ullman, 1974". | |
| The implementation uses a DFS to find the strongly connected components (SCCs) | |
| of a graph. During the DFS the vertices are placed on a stack in the order | |
| they are visited. Whenever a root is found, all vertices of the corresponding | |
| SSC are on the top of the stack and are popped. |
This file contains hidden or 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
| <blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" | |
| xmlns:camel="http://camel.apache.org/schema/blueprint" | |
| xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" | |
| xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> | |
| <camel:camelContext xmlns="http://camel.apache.org/schema/blueprint" id="paginationRouteContext"> | |
| </camel:camelContext> |
This file contains hidden or 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
| ActiveMQ Task-1] FailoverTransport INFO Successfully connected to tcp://MacBook-Pro.local:57022 | |
| [.local/172.28.1.21:57022@58129] FailoverTransport WARN Transport (tcp://MacBook-Pro.local/172.28.1.23:57022@58129) failed, reason: , attempting to automatically reconnect | |
| java.io.EOFException | |
| at java.io.DataInputStream.readInt(DataInputStream.java:392) | |
| at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:258) | |
| at org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:221) | |
| at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:213) | |
| at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:196) | |
| at java.lang.Thread.run(Thread.java:745) | |
| [ main] ZooKeeper INFO Session: 0x148d131f76d002b closed |
This file contains hidden or 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 derivation | |
| import shapeless._ | |
| import shapeless.ops.coproduct.Length | |
| import shapeless.ops.nat.ToInt | |
| import scala.util.Random | |
| sealed trait Animal | |
| case class Cat(name: String, fish: Int) extends Animal |
This file contains hidden or 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 scala.concurrent.duration._ | |
| import scala.concurrent.ExecutionContext | |
| import scala.concurrent.Future | |
| import akka.pattern.after | |
| import akka.actor.Scheduler | |
| /** | |
| * Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown, | |
| * in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through | |
| * the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure. |