slick-cats

Cats instances for Slick's DBIO

Лицензия

Лицензия

Группа

Группа

com.rms.miu
Идентификатор

Идентификатор

slick-cats_2.12
Последняя версия

Последняя версия

0.10.4
Дата

Дата

Тип

Тип

jar
Описание

Описание

slick-cats
Cats instances for Slick's DBIO
Ссылка на сайт

Ссылка на сайт

https://github.com/rmsone/slick-cats
Организация-разработчик

Организация-разработчик

com.rms.miu
Система контроля версий

Система контроля версий

https://github.com/rmsone/slick-cats

Скачать slick-cats_2.12

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.rms.miu/slick-cats_2.12/ -->
<dependency>
    <groupId>com.rms.miu</groupId>
    <artifactId>slick-cats_2.12</artifactId>
    <version>0.10.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.rms.miu/slick-cats_2.12/
implementation 'com.rms.miu:slick-cats_2.12:0.10.4'
// https://jarcasting.com/artifacts/com.rms.miu/slick-cats_2.12/
implementation ("com.rms.miu:slick-cats_2.12:0.10.4")
'com.rms.miu:slick-cats_2.12:jar:0.10.4'
<dependency org="com.rms.miu" name="slick-cats_2.12" rev="0.10.4">
  <artifact name="slick-cats_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.rms.miu', module='slick-cats_2.12', version='0.10.4')
)
libraryDependencies += "com.rms.miu" % "slick-cats_2.12" % "0.10.4"
[com.rms.miu/slick-cats_2.12 "0.10.4"]

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
org.scala-lang : scala-library jar 2.12.12
com.typesafe.slick : slick_2.12 jar 3.3.3
org.typelevel : cats-core_2.12 jar 2.3.1

test (4)

Идентификатор библиотеки Тип Версия
org.typelevel : cats-laws_2.12 jar 2.3.1
org.typelevel : discipline-scalatest_2.12 jar 2.1.1
org.scalatest : scalatest_2.12 jar 3.2.3
org.scalacheck : scalacheck_2.12 jar 1.15.2

Модули Проекта

Данный проект не имеет модулей.

SlickCats

Cats instances for Slick's DBIO including:

  • Monad
  • MonadError
  • CoflatMap
  • Group
  • Monoid
  • Semigroup
  • Comonad
  • Order
  • PartialOrder
  • Equals

Using

To add slick-cats dependency to a project, add the following to your build definition:

libraryDependencies += "com.rms.miu" %% "slick-cats" % version

Because of possible binary incompatibilities, here are the dependency versions used in each release:

slick-cats version slick version cats version
0.10.4 3.3.3 2.3.1
0.10.3 3.3.2 2.2.0
0.10.2 3.3.2 2.1.0
0.10.1 3.3.2 2.0.0

Artifacts are publicly available on Maven Central starting from version 0.6.

Accessing the Instances

Some or all of the following imports may be needed:

import cats._
import slick.dbio._
import com.rms.miu.slickcats.DBIOInstances._

Additionally, be sure to have an implicit ExecutionContext in scope. The implicit conversions require it and will fail with non-obvious errors if it's missing.

implicitly[Monad[DBIO]]
// error: Could not find an instance of Monad for slick.dbio.DBIO
// implicitly[Monad[DBIO]]
// ^^^^^^^^^^^^^^^^^^^^^^^
import scala.concurrent.ExecutionContext.Implicits.global

instances will be available for:

implicitly[Monad[DBIO]]
implicitly[MonadError[DBIO, Throwable]]
implicitly[CoflatMap[DBIO]]
implicitly[Functor[DBIO]]
implicitly[Applicative[DBIO]]

If a Monoid exists for A, here taken as Int, then the following is also available

implicitly[Group[DBIO[Int]]]
implicitly[Semigroup[DBIO[Int]]]
implicitly[Monoid[DBIO[Int]]]

Known Issues

Instances are supplied for DBIO[A] only. Despite being the same thing, type aliases will not match for implicit conversion. This means that the following

def monad[F[_] : Monad, A](fa: F[A]): F[A] = fa

val fail1: DBIOAction[String, NoStream, Effect.All] = DBIO.successful("hello")
// fail1: DBIOAction[String, NoStream, Effect.All] = SuccessAction("hello")
val fail2 = DBIO.successful("hello")
// fail2: DBIOAction[String, NoStream, Effect] = SuccessAction("hello")
val success: DBIO[String] = DBIO.successful("hello")
// success: DBIO[String] = SuccessAction("hello")

will not compile

monad(fail1)
monad(fail2)
// error: no type parameters for method monad: (fa: F[A])(implicit evidence$1: cats.Monad[F])F[A] exist so that it can be applied to arguments (slick.dbio.DBIOAction[String,slick.dbio.NoStream,slick.dbio.Effect.All])
//  --- because ---
// argument expression's type is not compatible with formal parameter type;
//  found   : slick.dbio.DBIOAction[String,slick.dbio.NoStream,slick.dbio.Effect.All]
//  required: ?F[?A]
// monad(fail1)
// ^^^^^
// error: type mismatch;
//  found   : slick.dbio.DBIOAction[String,slick.dbio.NoStream,slick.dbio.Effect.All]
//  required: F[A]
// monad(fail1)
//       ^^^^^
// error: no type parameters for method monad: (fa: F[A])(implicit evidence$1: cats.Monad[F])F[A] exist so that it can be applied to arguments (slick.dbio.DBIOAction[String,slick.dbio.NoStream,slick.dbio.Effect])
//  --- because ---
// argument expression's type is not compatible with formal parameter type;
//  found   : slick.dbio.DBIOAction[String,slick.dbio.NoStream,slick.dbio.Effect]
//  required: ?F[?A]
// monad(fail2)
// ^^^^^
// error: type mismatch;
//  found   : slick.dbio.DBIOAction[String,slick.dbio.NoStream,slick.dbio.Effect]
//  required: F[A]
// monad(fail2)
//       ^^^^^

but

monad(success)
// res10: DBIO[String] = SuccessAction("hello")

will compile fine.

Extras

This README is compiled using mdoc to ensure that only working examples are given.

com.rms.miu

MIU Team

Версии библиотеки

Версия
0.10.4
0.10.3
0.10.2
0.10.1
0.10.0
0.9.1
0.9.0
0.8.0.0
0.7.1.1
0.7.1
0.7.1-RC1
0.7-MF
0.7-RC3
0.7-RC2
0.7-RC1
0.6