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.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) |
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
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._ |
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 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] |
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
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 |
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
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._ |
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 squants.market.{JPY, MoneyContext, USD} | |
import squants.market.MoneyConversions._ | |
val rate = USD / 112.14.yen | |
// r: CurrencyExchangeRate = USD/JPY 112.14 | |
rate convert 10.dollars | |
// 1121.4 JPY | |
import squants.market.defaultMoneyContext |
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
// Analysis Patterns 3.1 | |
import squants.mass.MassConversions._ | |
val m1 = 185 pounds | |
// m1: Mass = 185.0 lb | |
val (q, u) = m1 toTuple // 必要なら数値と単位文字列に分けることもできる | |
// q: Double = 185.0 | |
// u: String = lb | |
import squants.market.MoneyConversions._ |
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
name := "squants_exercise" | |
version := "0.1" | |
scalaVersion := "2.12.8" | |
scalacOptions ++= Seq( | |
"-encoding", "utf8", | |
"-Xfatal-warnings", | |
"-Ypartial-unification", |
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 ciris.{ConfigKeyType, ConfigSource} | |
// Coproduct | |
import shapeless.{:+:, CNil} | |
import ciris.generic._ | |
val gType = ConfigKeyType[String]("generic key") | |
ConfigSource.fromEntries(gType)("key" -> "5.0") | |
.read("key").decodeValue[Float :+: String :+: CNil].result | |
// Right(Inl(5.0)) |
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
package exercise.ciris.qiita3 | |
import cats.effect.ExitCode.{Error, Success} | |
import cats.effect.{ExitCode, Sync} | |
import cats.syntax.functor._ | |
import ciris.api.{Apply => CApply} | |
import ciris.cats.effect._ | |
import ciris.{envF, loadConfig} | |
import monix.eval.{Task, TaskApp} | |
import scala.language.higherKinds |
NewerOlder