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.data.{EitherT, State, StateT} | |
import cats.Monad | |
import cats.syntax.flatMap._ | |
import cats.syntax.functor._ | |
import cats.instances.either._ | |
import cats.mtl.{FunctorRaise, MonadState} | |
import MonadState._ | |
import FunctorRaise._ | |
type MSI[F[_]] = MonadState[F, Int] |
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.data.State | |
import org.atnos.eff._ | |
import org.atnos.eff.all._ | |
import org.atnos.eff.syntax.all._ | |
object E { | |
type _eitherString[R] = Either[String, ?] |= R | |
type _stateInt[R] = State[Int, ?] |= R | |
def decr[R: _eitherString: _stateInt]: Eff[R, Unit] = for { |
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.qiita1 | |
import ciris.api.Id | |
import ciris.{ConfigEntry, ConfigErrors, ConfigResult, env, loadConfig, file} | |
import ciris.generic._ | |
case class Config(name: String) | |
object Main { | |
def main(args: Array[String]): Unit = { |
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
scalaVersion := "2.12.8" | |
val cirisVersion = "0.12.1" | |
addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.9") | |
scalacOptions ++= Seq( | |
"-encoding", "utf8", // Option and arguments on same line | |
"-Xfatal-warnings", // New lines for each options | |
"-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
package exercise.ciris.qiita1 | |
import ciris.api.Id | |
import ciris.{ConfigResult, env, withValues, loadConfig} | |
import ciris.generic._ | |
object MainMulti { | |
case class Config(name: String) | |
val config: ConfigResult[Id, Config] = |
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 |
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
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
// 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
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 |