Questions tagged [scala-cats]

Cats is a library that provides abstractions for functional programming in Scala.

Cats is a library that provides abstractions for functional programming in Scala.

The name is a playful shortening of the word category.

Official Website

Official Repository

929 questions
0
votes
1 answer

Return final result from nested for-comprehensions processing stacked State and IO monads

As a followup to this question I need to process all results collected in processResult. But when I run the code I get from println(finalBusinessResult) Edit: It seems to process step1 one and nothing else Q: How do get it to return the…
jakstack
  • 2,143
  • 3
  • 20
  • 37
0
votes
1 answer

Scalaz |-> counterpart in Cats

I noticed that the Scalaz |-> operator is not implemented in Cats. Is there a function offering similar semantics?
LuGo
  • 4,877
  • 1
  • 18
  • 19
0
votes
2 answers

Kittens - ambiguous imports (again)

This answer https://stackoverflow.com/a/56366311/2682459 shows how it is possible to use an object to provide a custom implementation of a typeclass when using Kitten. Applying the same principle to the following code though doesn't work: package…
user2682459
  • 999
  • 2
  • 13
  • 24
0
votes
1 answer

Cats ValidatedNec mapN with Case Class Error Types

I'd like to use the Cats ValidatedNec data type similarly to the example in the Cats documentation for Validated in the section Meeting applicative-- in my case, I'm parsing Strings from a file, validating against an appropriate regex for the field,…
Timothy Perrigo
  • 723
  • 4
  • 18
0
votes
1 answer

Scala Cats spy a method with mockito-scala-cats

I am trying to mock a method with mockito-scala-cats For example this is my class class MyService { def getProperty(property: String): Either[Future, String, ExternalUser] = ??? } and the test class class MyServiceSpec extends FunSpec with…
agusgambina
  • 6,229
  • 14
  • 54
  • 94
0
votes
1 answer

How execute spring repository method in for comprehension with implicit

I want to save data from telegram api in for comprehension type with implicit, but have an error Error:(61, 9) type mismatch; found : cats.effect.IO[Unit] required: scala.concurrent.Future[?] _ <-…
Vadim
  • 753
  • 8
  • 22
0
votes
1 answer

Scala, cats - convert FUUID with Circe

I use this library https://christopherdavenport.github.io/fuuid/ for creating ID of custom object and persist them into databse. I have a simple case class which is my model: import io.chrisdavenport.fuuid.FUUID case class Bet( betId:…
Developus
  • 1,400
  • 2
  • 14
  • 50
0
votes
1 answer

Scala monads - "value map is not a member of" error

I have created a simple trait and service: @finalAlg @autoFunctorK(true) trait BettingService[F[_]] { def put(bet: Bet): F[Bet] } class BettingServiceMock[F[_] : Async] extends BettingService[F] { override def put(bet: Bet): F[Bet] = { …
Developus
  • 1,400
  • 2
  • 14
  • 50
0
votes
1 answer

Can't make simple tagless final example

I've read about tagless final and I think it's great. I wanted to build my own small example of this pattern and got the problem. This is my code: trait Calculator[F[_]] { def sum(a: Int, b: Int): F[Either[Throwable, Int]] def minus(a:…
faoxis
  • 1,912
  • 5
  • 16
  • 31
0
votes
1 answer

How to use functors with scala/cats

Aloha! :) Could please somebody point me to a useful scala/cats tutorial? I’m struggling with making a class a functor for the last few days and I’m about to punch a hole in my display. All the documentation I’ve found up until now was not of help…
0
votes
1 answer

Scala: ReaderT composition with different contexts and dependencies

Example of s3f1 and s3f2 functions that return different ReaderT: type FailFast[A] = Either[List[String], A] trait Service1 { def s1f:Option[Int] = Some(10) } trait Service2 { def s2f:FailFast[Int] = Right(20) } import cats.instances.option._ def…
Alexandr
  • 9,213
  • 12
  • 62
  • 102
0
votes
1 answer

Scala: write for-comprehension with ReaderT and Option

Here is example: trait Service1 { def s1f = Option(10) } trait Service2 { type ReaderS1[A] = ReaderT[Option,Service1,A] def s2f1: ReaderS1[Int] = ReaderT(s1 => for { r1 <- Option(1) r2 <- s1.s1f } yield r1 + r2 …
Alexandr
  • 9,213
  • 12
  • 62
  • 102
0
votes
1 answer

Scala-Cats: Compose monadic with applicative effects

Here are function definitions that return ReaderT: def f1:ReaderT[FailFast, Map[String,String], Boolean] = ReaderT(_ => Right(true)) def f2:ReaderT[FailFast, Map[String,String], Boolean] = ReaderT(_ => Left(List("d"))) def f3:ReaderT[FailFast,…
Alexandr
  • 9,213
  • 12
  • 62
  • 102
0
votes
1 answer

Scala-cats, compose Reader with ReaderT

Here is a small composition of functions, all of which return ReaderT: type FailFast[A] = Either[List[String], A] def f1:ReaderT[FailFast, Map[String,String], Boolean] = ReaderT(_ => Right(true)) def f2:ReaderT[FailFast, Map[String,String],…
Alexandr
  • 9,213
  • 12
  • 62
  • 102
0
votes
1 answer

Do we still lose context in some monads with Semigroupal?

I'm reading the book "Scala with cats". The author says that Semigroupal doesn't always provide the behaviour we expect. And he shows this example: import cats.Semigroupal import cats.instances.future._ // for Semigroupal import…
faoxis
  • 1,912
  • 5
  • 16
  • 31