There are two possible definitions of a somewhat higher order Functor
s:
HFunctorA
:
trait HFunctorA[H[_[_],_]] {
def map[F[_], G[_], A](h: H[F, A])(f: F ~> G): H[G, A]
}
and HFunctorB
:
trait HFunctorB[H[_[_]]] {
var Note = Backbone.Model.extend({ | |
initialize: function() {}, | |
delete: function() { | |
//do something | |
this.log('deleted'); | |
}, | |
log: function(msg) { | |
alert(msg); |
def createOrUpdateCard( profileId: ProfileId, contextName: ContextName): FutureEither[CardId] = { | |
lazy val nowF = getAndValidateGoogleNowCredential(profileId) | |
lazy val contentF = getContentFromStationService(profileId, contextName) | |
lazy val contextF = ensureContextExistsOnGoogle(contextName) | |
def createCard = { | |
for { | |
now <- nowF | |
content <- contentF |
package com.iheart.play.akka | |
import org.specs2.mutable.Specification | |
import shapeless._ | |
import ops.hlist._ | |
import shapeless.ops.record.{Values, Keys} | |
import syntax.singleton._ | |
object Test { | |
case class RawReq(ip: String, header: Map[String, String] = Map()) |
val endpoint0 = handle( | |
fromJson[PartialRequestMessage].body and from(req ⇒ 'name ->> req.headers("my_name") :: HNil), | |
process[RequestMessage] using myActor `then` expect[ResponseMessage].respondJson(Ok(_)) | |
) | |
val endPoint1 = handleParams( | |
process[RequestMessage] using myActor `then` expect[ResponseMessage].respond(Ok) `with` authentication | |
) | |
object overloaded extends Overload { | |
implicit def futureT[T] = | |
Case((t: Future[T]) => t.map(Right(_)) | |
implicit def futureOptT[T, U](implicit ev: U <:< Option[T]) = | |
Case((t: Future[U]) => t.map(Right(_.get)).getOrElse(Left(NotFoundException)) | |
} |
trait AnimalMouth | |
class Beak extends AnimalMouth | |
//================================Generic type works as in the following ======================= | |
trait Animal[Mouth <: AnimalMouth] { | |
def mouth : Mouth | |
def feedAnother(m: Mouth): Unit = () | |
} |
object Test { | |
type Cause = String | |
type FutureXor[A] = XorT[Future, Cause, A] | |
case class ProcessContext[+A](context: List[String], data: A) //context never need to change | |
trait Processor[-A, B] extends Serializable { | |
def process: ProcessContext[A] ⇒ FutureXor[B] |
import org.apache.avro.io.DatumReader | |
import org.apache.avro.io.DecoderFactory | |
import org.apache.avro.specific.SpecificDatumReader | |
import org.apache.flink.api.common.typeinfo.TypeInformation | |
import org.apache.flink.api.java.typeutils.TypeExtractor | |
class AvroDeserializationSchema[T <: SpecificRecordBase: ClassTag](private val baselineMessage: () ⇒ T) extends DeserializationSchema[T] { | |
override def deserialize(message: Array[Byte]): T = { |
import cats.{Applicative, Unapply} | |
import cats.instances.all._ | |
import shapeless._ | |
object Test { | |
trait Foo[L <: HList] | |
object Foo extends MkFoo |
There are two possible definitions of a somewhat higher order Functor
s:
HFunctorA
:
trait HFunctorA[H[_[_],_]] {
def map[F[_], G[_], A](h: H[F, A])(f: F ~> G): H[G, A]
}
and HFunctorB
:
trait HFunctorB[H[_[_]]] {