Skip to content

Instantly share code, notes, and snippets.

trait Coercible[A, B] {
def coerce(a: A): B
}
def coerce[A, B](a: A)(implicit coerceAB: Coercible[A, B]): B = {
coerceAB.coerce(a)
}
trait Newtype[+T] {
val value: T
import scala.annotation.tailrec
object FoldFun {
// Option
// List
// Vector
trait Foldable[F[_]]{ self =>
import cats.Monoid
import cats.Eval
import cats._
import cats.data._
import cats.implicits._
import cats.effect._
import scala.util.Try
object LoggingInPureFunctions {
// Writer[Vector[String], ?]
import cats._
import cats.data._
import cats.implicits._
object ValidateMyExistence {
// Say you are writing a password change application.
// You are given a username, an old password, and a new password
case class PasswordChangeRequest(username: String, oldPassword: String, newPassword: String)
// We have a set of rules we would like to enforce on this data,
// and would like to ensure that all of them are correct,
@julianpeeters
julianpeeters / test.avdl
Last active November 26, 2015 00:56 — forked from delagoya/test.avdl
Avro IDL comments to Avrodoc example 2
@namespace("com.example")
/**
This is a comment for the whole protocol
*/
protocol Example {
/**
The comment applies to the `NoSpaces` record, but is not indented to the