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 cats | |
import cats.data.{StateT, WriterT} | |
import cats.implicits._ | |
/** | |
* TypeLevel is working on some alternative encodings of the Monad Transformer | |
* Library (MTL). The existing solution in cats was broken for a few reasons. | |
* One annoying issue made it imposisible to use for-comprehension with more | |
* than one Monad$FOO constraint owing to implicit resolution ambiguities. |
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 scala.language.higherKinds | |
object Lenses { | |
trait Profunctor[P[_, _]] { | |
def dimap[A, B, C, D](f: C => A, g: B => D)(p: P[A, B]): P[C, D] | |
} | |
object Profunctor { |
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 scalaz._, Scalaz._ | |
/** Abstraction over functions of the shape `A => F[A]`. */ | |
case class EndoT[F[_], A](run: A => F[A]) { | |
def apply(a: A): F[A] = | |
run(a) | |
def andThen(e: EndoT[F, A])(implicit ev: Bind[F]): EndoT[F, A] = | |
e.compose(this) |
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 cats.bench | |
import cats.data.Xor | |
import cats.instances.either._ | |
import cats.syntax.all._ | |
import org.openjdk.jmh.annotations.{ Benchmark, Scope, State } | |
@State(Scope.Benchmark) | |
class EitherBench { | |
val ea: Either[String, Int] = Right(1) |
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
/** | |
* Single-file play framework application! Make sure everything | |
* works, as this is the test case that un-earthed #371 | |
*/ | |
load.ivy("com.typesafe.play" %% "play" % "2.5.0") | |
load.ivy("com.typesafe.play" %% "play-netty-server" % "2.5.0") | |
load.ivy("org.scalaj" %% "scalaj-http" % "2.2.1") | |
@ |
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 akka.kafka.scaladsl | |
import java.util.concurrent.TimeUnit | |
import java.util.{Properties, UUID} | |
import akka.actor.ActorSystem | |
import akka.kafka.{ConsumerSettings, ProducerSettings} | |
import akka.stream.ActorMaterializer | |
import akka.stream.scaladsl.Sink | |
import akka.testkit.TestKit |
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
# Set bluetooth power up | |
ACTION=="add", SUBSYSTEM=="bluetooth", KERNEL=="hci[0-9]*", RUN+="/bin/hciconfig %k up" |
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
def treeDoc(t: Tree): Doc = t match { | |
case PackageDef(mods, pid, xs) => mods <> "package" <+> pid <+> xs.inBracesBlock | |
case Import(expr, selectors) => "import" <+> expr <> dot <> selectors | |
case NamedImport(name) => name | |
case TypeIdent(pre, name) => (pre :+ name).joinDotted | |
case TermIdent(pre, name) => (pre :+ name).joinDotted | |
case ClassDef(mods, keyword, name, tparams, vparamss, impl) => linebreak <> mods <> keyword <+> name <> tparams <> tight(vparamss) <> doTemplate(line <> "extends", impl) | |
case TypeParam(mods, name, tparams, constraints) => mods <> name <> tparams <> constraints | |
case ValueParam(mods, name, tpt, defaultValue) => mods <> name <> tpt <> opt(space <> assign, defaultValue) | |
case x: Name => x.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
/* | |
* Copyright (c) 2015 Miles Sabin | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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 ConsoleAlg[F[_]] { | |
def readLine: F[Option[String]] | |
def printLine(line: String): F[Unit] | |
} | |
trait Console[+A] { | |
def run[F[+_]](F: ConsoleAlg[F]): F[A] | |
} | |
object Console { |
NewerOlder