Symbol | Name | Typeclass | import |
---|---|---|---|
` | @ | ` | Cartesian Builder |
=== |
Equals | Eq |
cats.syntax.eq._ |
=!= |
Not Equals | Eq |
cats.syntax.eq._ |
` | + | ` | Semigroup plus |
<+> |
SemigroupK combine | SemigroupK |
cats.syntax.semigroupk._ |
~> |
Natural transformation | N/A | cats._ |
⊥ |
Bottom | N/A | cats._ |
⊤ |
Top | N/A | cats._ |
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
enum Pull { | |
case Done | |
case Output(name: String) | |
case UnconsThen(pull: Pull, f: Option[(String, Pull)] => Pull) | |
case Then(pull: Pull, next: () => Pull) | |
} | |
import Pull._ | |
val done = Done | |
def single(name: String) = Output(name) |
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
enum Pull[A] { | |
case Pure[A](value: A) extends Pull[A] | |
case Output(name: String) extends Pull[Unit] | |
case Uncons[A](pull: Pull[A]) extends Pull[Option[(String, Pull[A])]] | |
case FlatMap[A, B](pull: Pull[A], f: A => Pull[B]) extends Pull[B] | |
} | |
import Pull._ | |
val done: Pull[Unit] = Pure(()) | |
def single(name: String): Pull[Unit] = Output(name) |
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 game | |
/** Game logic: | |
* | |
* The game map is a tiled grid. Each tile has something on it. | |
* | |
* Actions: | |
* When a citizen is clicked on, they can be told to do something. | |
* At the moment, they can only chop wood. | |
* |
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 foo | |
import shapeless._ | |
import shapeless.labelled.FieldType | |
import shapeless.ops.hlist._ | |
/** This example zips two hlists together based on their keys and part of their values | |
* | |
* | |
* A left HList of type FieldType[Key, (A, LB)] :: LTail is zipped with a right HList which contains FieldType[Key, (A, RB)] |
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 Refute[A] | |
object Refute { | |
implicit def ambiguous1[A](implicit ev: A): Refute[A] = new Refute[A] {} | |
implicit def ambiguous2[A](implicit ev: A): Refute[A] = new Refute[A] {} | |
implicit def refute[A]: Refute[A] = new Refute[A] {} | |
} | |
object TestRefute { | |
trait 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
object gist { | |
import shapeless._ | |
trait Semigroup[A] { | |
def combine(a0: A, a1: A): A | |
} | |
implicit final class SemigroupCombineOps[A](a0: A)(implicit S: Semigroup[A]) { | |
def combine(a1: A): A = S.combine(a0, a1) |
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 drone | |
import fs2._ | |
import java.time.Instant | |
import java.util.UUID | |
object Time { | |
def local: Task[Instant] = Task.delay(Instant.now()) | |
} |
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
//local defined for GlobalEnv => Option[LocalEnv] | |
def localOption[LocalEnv, GlobalEnv, A](r: Reader[LocalEnv, A])(f: GlobalEnv => Option[LocalEnv]): Reader[GlobalEnv, Option[A]] = | |
Reader(globalEnv => f(globalEnv).map(r.run)) | |
//generalization of the above in terms of Functors | |
def localF[F[_], A, AA, B](r: Reader[A, B])(f: AA => F[A])(implicit F: Functor[F]): Reader[AA, F[B]] = | |
Reader(aa => f(aa).map(r.run)) | |
//generalization of the above in terms of Kleislis | |
def localFK[F[_], A, AA, B](r: Kleisli[Id, A, B])(f: AA => F[A])(implicit F: Functor[F]): Kleisli[F, AA, B] = |
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
;; the package manager | |
(require 'package) | |
(setq | |
use-package-always-ensure t | |
package-archives '(("gnu" . "http://elpa.gnu.org/packages/") | |
("org" . "http://orgmode.org/elpa/") | |
("melpa" . "http://melpa.org/packages/"))) | |
(package-initialize) | |
(when (not package-archive-contents) |