Coder Social home page Coder Social logo

slick-cats's Introduction

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.5 3.4.1 2.9.0
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]]
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")
val fail2 = DBIO.successful("hello")
val success: DBIO[String] = DBIO.successful("hello")

will not compile

monad(fail1)
monad(fail2)

but

monad(success)

will compile fine.

Extras

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

slick-cats's People

Contributors

frosforever avatar tvaroh avatar 23will avatar plavreshin avatar timothyklim avatar karolchmist avatar daenyth avatar mwz avatar dsiglow avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.