I hereby claim:
- I am kailuowang on github.
- I am kailuowang (https://keybase.io/kailuowang) on keybase.
- I have a public key ASAwfpUUT9j_iHqjCdCz_cyjnswRisAinmoqwPo0YpMgzQo
To claim this, I am signing this object:
trait IsoK[F[_], G[_]] { self => | |
def from[A](fa: F[A]): G[A] | |
def to[A](ga: G[A]): F[A] | |
def flip: IsoK[G, F] = new IsoK[G, F] { | |
def from[A](ga: G[A]): F[A] = self.to(ga) | |
def to[A](fa: F[A]): G[A] = self.from(fa) | |
} |
import cats.effect.{Resource, Sync} | |
import cats.implicits._ | |
import com.google.api.gax.core.FixedCredentialsProvider | |
import com.google.auth.oauth2.GoogleCredentials | |
import com.google.cloud.language.v1.{LanguageServiceClient, LanguageServiceSettings} | |
object GoogleClient { | |
case object S3ObjectNotFound extends RuntimeException |
I hereby claim:
To claim this, I am signing this object:
trait RuleSetDSL[P] { | |
type Check1[A1, A2] = Checkable1[A1, A2, P] | |
type Check2[A1, A2, A3] = Checkable2[A1, A2, A3, P] | |
implicit def law[A1, A2](s : String, f: A1 => IsEq[A2])(implicit toP1: Check1[A1, A2]): (String, P) = | |
(s, toP1(f)) |
import Dependencies._ | |
ThisBuild / scalaVersion := "2.12.8" | |
ThisBuild / version := "0.1.0-SNAPSHOT" | |
ThisBuild / organization := "com.example" | |
ThisBuild / organizationName := "example" | |
lazy val root = (project in file(".")) | |
.aggregate(mA, mB) | |
.settings( |
import com.stripe.rainier.repl._ | |
import com.stripe.rainier.core._ | |
val data = Gamma(0.5, 3).param.sample() | |
val ap = for { | |
a <- Normal(0.5, 0.05).param | |
b <- Normal(3, 0.1).param | |
d <- Gamma(a, b).fit(data) |
import cats.implicits._ | |
import implicits._ | |
import java.time.Instant | |
import cats.Functor | |
import org.openjdk.jmh.annotations.{Benchmark, Scope, State} | |
case class Foo[A](a: A) |
Divide and conquer has been a core strategy in software engineering. We decompose our systems into smaller modules with focused, simple functionalities and compose them back to provide richer features. In a complex modular system, developers regularly have to dedicate a significant portion of code and effort to such composition.
Needless to say, it provides major benefits to be able to compose and decompose computation with ease. This is where FP, i.e. Functional Programming mainly focuses on. For developers who wonder what difference FP makes, this blog post aims to give a taste of how it enables more natural composition. I am going to focus on one particular and yet common factor that makes computation composition cumbersome in imperative programming - effects.
Let's start with two functions with the return type of one matching the input type of the other. That is, given
There are two possible definitions of a somewhat higher order Functor
s:
HFunctorA
:
trait HFunctorA[H[_[_],_]] {
def map[F[_], G[_], A](h: H[F, A])(f: F ~> G): H[G, A]
}
and HFunctorB
:
trait HFunctorB[H[_[_]]] {
import cats.{Applicative, Unapply} | |
import cats.instances.all._ | |
import shapeless._ | |
object Test { | |
trait Foo[L <: HList] | |
object Foo extends MkFoo |