Skip to content

Instantly share code, notes, and snippets.

View yasuabe's full-sized avatar

Yasuyuki Abe yasuabe

View GitHub Profile
@yasuabe
yasuabe / Main.scala
Created April 18, 2019 13:33
squants exercise with pureconfig
package exercise.squants.with_pureconfig
import pureconfig.ConfigReader.Result
import squants.motion.Pressure
import pureconfig.module.squants._
import pureconfig.generic.auto._
import squants.Mass
import squants.thermal._
import squants.space._
@yasuabe
yasuabe / Main.scala
Created April 18, 2019 13:36
squants exercise with Circe
package exercise.squants.with_circe
import eu.timepit.refined.types.string.NonEmptyString
import io.circe.parser.parse
import squants.market.{Money, Price}
import cats.syntax.either._
import io.circe.refined._
import io.circe._
import io.circe.generic.auto._
import squants.space.Volume
@yasuabe
yasuabe / di_with_zio.sc
Last active April 25, 2019 13:24
dependency injection sample with ZIO
import scalaz.zio.{DefaultRuntime, IO, ZIO}
// domain layer -----------------------------------------------------------
sealed trait AppError
case object NoValue extends AppError
case class Movie(id: Int, title: String)
trait MovieRepo {
def getMovie(id: Int): IO[AppError, Movie]
@yasuabe
yasuabe / ArtistIndex.scala
Created May 10, 2019 11:40
simple elastic4s sample using Cats Effect and Circe
package trial1
import cats.effect._
import cats.instances.list._
import cats.syntax.flatMap._
import cats.syntax.functor._
import cats.syntax.traverse._
import com.sksamuel.elastic4s.circe._
import com.sksamuel.elastic4s.http.search.SearchResponse
import com.sksamuel.elastic4s.http._
import cats.Order
import cats.collections.PairingHeap
import cats.instances.long._
import PairingHeap.empty
type Longs = Stream[Long]
implicit val x: Order[Longs] = (x, y) => x.head compare y.head
def spin(start: Long, wheel: Longs): Longs = {
def cycle(ns: Longs): Longs = ns append cycle(ns)