Skip to content

Instantly share code, notes, and snippets.

View yasuabe's full-sized avatar

Yasuyuki Abe yasuabe

View GitHub Profile
@yasuabe
yasuabe / ConcurrentEffectDemo.scala
Created February 1, 2019 12:53
Cats Effect ConcurrentEffect example
package cats_effect_typeclass_exericise.concurrent_effect
import java.time.format.DateTimeFormatter
import cats.data.{Chain, EitherT, WriterT}
import cats.effect._
import scala.language.higherKinds
object Util {
@yasuabe
yasuabe / Prob.scala
Created February 7, 2019 05:21
probability monad(from LYAHFGG) in scala
package ex01
import cats.Monad
import scala.annotation.tailrec
sealed trait Coin
case object Heads extends Coin
case object Tails extends Coin
@yasuabe
yasuabe / publish_subscribe_test.scala
Created February 28, 2019 14:26
publish/subscribe with monix observable
package observable
import cats.effect.ExitCode
import monix.eval.{Task, TaskApp}
import monix.execution.Ack
import monix.execution.Ack.{Continue, Stop}
import monix.reactive.{Consumer, Observable, Observer}
import scala.concurrent.Future
import scala.concurrent.duration._
@yasuabe
yasuabe / SimpleMain.scala
Last active March 20, 2019 18:14
a simple example of hammock http client with Cats Effect IO and Apache HttpComponents Client
package qiita_sample1
import cats.effect.{ExitCode, IO, IOApp}
import cats.free.Free
import hammock._
import hammock.apache.ApacheInterpreter
object SimpleMain extends IOApp {
val program: Free[HttpF, HttpResponse] = Hammock
.request(Method.GET, uri"http://httpbin.org/get", Map())
@yasuabe
yasuabe / ComposedFreeMain.scala
Created March 20, 2019 18:21
a composed free monads sample of Hammock with Apache HttpComponents Client and monix Task
package qiita_sample1
import cats.{InjectK, ~>}
import cats.effect.{ExitCode, Sync}
import cats.free.Free
import cats.syntax.either._
import iota.TListK.:::
import iota.{CopK, TNilK}
object Console {
@yasuabe
yasuabe / SimpleSampleMain.scala
Created March 26, 2019 22:16
simple program for examining Doobie with Monix Task
package doobie_top
import doobie._
import doobie.implicits._
import cats.effect._
import monix.eval.{Task, TaskApp}
case class Country(code: String, name: String, population: Long)
object SimpleSampleMain extends TaskApp {
@yasuabe
yasuabe / ServerMain.scala
Created March 26, 2019 22:20
simple http4s server program for examining Doobie
package withhttp4s
import cats.effect.{IO, IOApp}
import cats.implicits._
import org.http4s.{HttpApp, HttpRoutes}
import org.http4s.implicits._
import org.http4s.server.blaze._
import cats.effect._
import doobie._
import doobie.implicits._
@yasuabe
yasuabe / MyServiceSpec.scala
Created March 26, 2019 22:23
simple spec test for Doobie
package withhttp4s
import cats.effect.{ContextShift, IO}
import doobie.specs2.IOChecker
import org.specs2.mutable.Specification
object MyServiceSpec extends Specification with IOChecker {
import scala.concurrent.ExecutionContext.Implicits.global
implicit val cs: ContextShift[IO] = IO.contextShift(global)
@yasuabe
yasuabe / first_doobie_test_build.sbt
Created March 26, 2019 22:36
build.sbt for doobie test
name := "doobie_test"
version := "0.1"
scalaVersion := "2.12.8"
resolvers += Resolver.sonatypeRepo("snapshots")
scalacOptions ++= Seq(
"-encoding", "utf8",
@yasuabe
yasuabe / SimpleMain.scala
Created March 31, 2019 08:36
simple test main for ZIO Environment
import scalaz.zio.{App, IO, ZIO}
import scala.io.StdIn
// "org.scalaz" %% "scalaz-zio" % "1.0-RC3"
object SimpleMain extends App {
sealed trait AppError
case object NoValue extends AppError
def valueOf(key: String): ZIO[Map[String, String], AppError, String] =