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 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 |
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.annotation.tailrec | |
| object FoldFun { | |
| // Option | |
| // List | |
| // Vector | |
| trait Foldable[F[_]]{ self => | |
| import cats.Monoid | |
| import cats.Eval |
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._ | |
| import cats.data._ | |
| import cats.implicits._ | |
| import cats.effect._ | |
| import scala.util.Try | |
| object LoggingInPureFunctions { | |
| // Writer[Vector[String], ?] |
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._ | |
| 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, |
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
| @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 |