Skip to content

Instantly share code, notes, and snippets.

View yasuabe's full-sized avatar

Yasuyuki Abe yasuabe

View GitHub Profile
@yasuabe
yasuabe / QueueTestApp.scala
Last active September 23, 2019 12:18
fs2 queue sample in which stdin and timer streams enqueue data and dequeuer side prints to stdout
package qiita
import cats.effect._
import cats.syntax.functor._
import fs2.concurrent.Queue
import fs2.{Pipe, Stream, io, text}
import scala.concurrent.duration._
import scala.language.postfixOps
@yasuabe
yasuabe / TopicDemoApp.scala
Last active September 22, 2019 17:10
fs2 concurrency topic demo. To run this, uncomment ConcurrencyDemoApp and package object and move them to appropriate place.
package qiita
import fs2.concurrent.{SignallingRef, Topic}
import fs2.{INothing, io, text}
import scala.concurrent.duration._
import scala.language.postfixOps
sealed trait Event
case object Start extends Event
@yasuabe
yasuabe / BalanceDemoApp.scala
Last active May 3, 2020 08:46
fs2.concurrent Balance and Broadcast demo. To run these, uncomment ConcurrentyDemoApp.
package qiita
import cats.effect._
import cats.syntax.functor._
import fs2.{Pipe, Stream, io, text}
import scala.concurrent.duration._
import scala.language.postfixOps
trait ConcurrencyDemoApp extends IOApp {
@yasuabe
yasuabe / iota_qiita.sc
Last active October 5, 2019 13:39
Iota demo. Applied to cats free monad sample.
import cats.data.{State, Chain}
import cats.free.Free
import cats.~>
import iota.TListK.:::
import iota.{CopK, TNilK}
sealed trait Interact[A]
case class Ask(prompt: String) extends Interact[String]
case class Tell(msg: String) extends Interact[Unit]
@yasuabe
yasuabe / BracketDemo.scala
Created January 30, 2019 15:43
cats effect bracket type class demo
package cats_effect_typeclass_exericise.bracket
import java.time.format.DateTimeFormatter
import cats.MonadError
import cats.data.Kleisli
import cats.effect.ExitCase.{Canceled, Completed, Error}
import cats.effect._
import cats.effect.concurrent.Ref
import cats.syntax.either._
@yasuabe
yasuabe / LiftIODemo.scala
Created January 31, 2019 04:54
sample code of Cats Effect LiftIO.liftIO
package cats_effect_typeclass_exericise.liftio
import java.time.format.DateTimeFormatter
import cats.data.{Chain, Kleisli, WriterT}
import cats.effect._
import scala.language.higherKinds
import scala.util.Try
import LiftIODemoUtil._
import cats.instances.either._
@yasuabe
yasuabe / SyncDemo.scala
Created January 31, 2019 10:30
Cats Effect Sync demo
package cats_effect_typeclass_exericise.sync
import java.time.format.DateTimeFormatter
import cats.effect.{ExitCode, IO, IOApp, Sync}
import cats.instances.list._
import cats.syntax.parallel._
import cats.syntax.functor._
import cats.syntax.flatMap._
object Util {
@yasuabe
yasuabe / AsyncDemo.scala
Last active February 1, 2019 12:46
Cats Effect Async Demo
package cats_effect_typeclass_exericise.async
import java.time.format.DateTimeFormatter
import cats.data.IorT
import cats.effect._
import cats.instances.string._
import scala.concurrent.Future
import scala.language.higherKinds
@yasuabe
yasuabe / ConcurrentDemoApp.scala
Created February 1, 2019 12:49
Cats Effect Concurrent examples
package cats_effect_typeclass_exericise.concurrent
import java.time.format.DateTimeFormatter
import java.util.concurrent.{ScheduledExecutorService, ScheduledFuture}
import cats.effect._
import scala.concurrent.duration._
import scala.language.higherKinds
@yasuabe
yasuabe / EffectDempApp.scala
Created February 1, 2019 12:51
Cats Effect Effect example
package cats_effect_typeclass_exericise.effect
import java.time.format.DateTimeFormatter
import cats.data.{Chain, WriterT}
import cats.effect._
import scala.language.higherKinds
object Util {