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 Semigroup[A] { def combine(a: A, b: A): A } | |
object Semigroup { def apply[A](a: A, b: A)(implicit ev: Semigroup[A]): A = ev.combine(a, b) } | |
implicit object StrSemi extends Semigroup[String] { def combine(a: String, b: String): String = a + b } | |
implicit def SemiTuple2[A, B](implicit ev1: Semigroup[A], ev2: Semigroup[B]): Semigroup[(A, B)] = new Semigroup[(A, B)] { | |
def combine(a: (A, B), b: (A, B)): (A, B) = (ev1.combine(a._1, b._1), ev2.combine(a._2, b._2)) | |
} | |
def buildInstance(size: Int) = { | |
val instanceName = Term.Name(s"SemiTuple${size}") | |
val (tparms, types) = (1 to size).toList.map({ i => | |
val tname = Type.Name(s"A${i}") |
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
#!/bin/sh | |
rebase_head_exists() { | |
[ -f "${GIT_ROOT}/REBASE_HEAD${1}" ] | |
} | |
rebase_merge_exists() { | |
[ -d "${GIT_ROOT}/rebase-merge${1}" ] | |
} |
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 blep | |
import cats.{ Id, Monad } | |
import scala.meta._ | |
sealed trait BlepTerm[T] | |
case class WritePackageObject() extends BlepTerm[Long] | |
object BlepGenerator { | |
def wat[T](value: BlepTerm[T]): Id[T] = value match { |
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 cats._, cats.arrow._, cats.data._, cats.free._, cats.implicits._ | |
import scala.meta.{ Import, Source } | |
package object foo { | |
type Target[T] = Either[String, T] | |
val Target = Monad[Target] | |
} | |
package foo { |
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
> compile | |
[info] Compiling 1 Scala source to /Users/dstewart/Projects/guardrail/modules/codegen/target/scala-2.12/classes... | |
[error] /Users/dstewart/Projects/guardrail/modules/codegen/src/main/scala/com/twilio/guardrail/CLI.scala:17: type mismatch; | |
[error] found : CLICommon.algebra.CoreTerms | |
[error] required: CLICommon.common.A.CoreTerms | |
[error] common.runM(algebra.coreTerm) | |
[error] ^ | |
[error] one error found | |
[error] (codegen/compile:compileIncremental) Compilation failed | |
[error] Total time: 0 s, completed Nov 5, 2018 10:53:10 PM |
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> Foo.buildBar.baz(_, _) | |
res0: (Int, Int) => Int = <function2> | |
scala> res0(1,2) | |
Hello! | |
res1: Int = 3 | |
scala> res0(1,2) | |
Hello! | |
res2: Int = 3 |
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
publish: | |
./scripts/publish-to-gollum --prepare-docs-target --overwrite | |
sbt -no-colors tut | |
./scripts/publish-to-gollum --publish-docs --overwrite |
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
[error] .../App2.scala:9: type mismatch; | |
[error] found : input.type (with underlying type H#Input) | |
[error] required: RouteService.this.Holder.Input | |
[error] def extractFoo(input: H#Input): Foo = Holder.input2Foo(input) | |
[error] ^ | |
[error] one error found | |
[error] (core/compile:compileIncremental) Compilation failed | |
[error] Total time: 0 s, completed Oct 23, 2016 11:15:51 PM |
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.Future | |
object App extends App { | |
val play = new RouteService[PlaySpec] { | |
def handle(req: PlayRequest) = Future.successful(new PlayResponse) | |
def addCookie(request: PlayRequest, cookie: PlayCookieAtom): PlayRequest = request.copy(cookie :: request.cookies) | |
} | |
val akka = new RouteService[AkkaSpec] { | |
def handle(req: AkkaRequest) = Future.successful(new AkkaResponse) |
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
sealed trait ControlPanel[T] | |
case object ButtonPressed extends ControlPanel[Button] | |
case object StopEnabled extends ControlPanel[Unit] | |
case object StopDisabled extends ControlPanel[Unit] | |
case object CurrentFloor extends ControlPanel[Int] | |
sealed trait ElevatorControl[T] | |
case object GetFloor extends ElevatorControl[Int] | |
case class QueueFloor(x: Int) extends ElevatorControl[Unit] |