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
2 answers

Simple unit testing with monoids

Suppose I testing a function echo: String => String, which is just repeating the input, with specs2. I can write a few tests like that: class EchoSpec extends SpecificationWithJUnit { "echo should handle ASCII alphanumeric names" in { …
Michael
  • 41,026
  • 70
  • 193
  • 341
0
votes
1 answer

Merging multiple Validated into single one

I have written this code def valid1() : Validated[List[String], Boolean] = {...} def valid2() : Validated[List[String], Boolean] = {...} def valid3() : Validated[List[String], Boolean] = {...} def valid4() : Validated[List[String], Boolean] =…
Knows Not Much
  • 30,395
  • 60
  • 197
  • 373
0
votes
1 answer

How to fix this compilation error with a Poly function

I am trying to map an HList of Xor to an HList of ValidatedNel and got an error: scala> type Result[A] = Xor[String, A] defined type alias Result scala> type Validation[A] = ValidatedNel[String, A] defined type alias Validation scala> val r0 =…
Michael
  • 41,026
  • 70
  • 193
  • 341
0
votes
1 answer

scala: Parameterize by Type Union

I needed a type Union to force restriction on types, So as per answer in here, I defined my Union as: sealed trait Value[T] object Value{ implicit object NumberWitness extends Value[Int] implicit object StringWitness extends…
bistaumanga
  • 1,476
  • 4
  • 16
  • 23
0
votes
1 answer

Scala Unable to pimp NaturalTransformation in scalaz or cats

For some reason the following fails to work object NtExtTest { implicit class NaturalTransformExt[M[_], N[_]](val self: NaturalTransformation[M,N]) extends AnyVal { def test(b:Boolean) = b } } when I call the method test on a natural…
J Pullar
  • 1,915
  • 2
  • 18
  • 30
0
votes
2 answers

Working with Streams wrapped in Options

I am working with some nested Streams and would like to use the for comprehension syntax with them: def handleNestedStream(as : Stream[A]) : Stream[(A, B)] = { a <- as b <- makeBs(a) } yield (a, b) However, the makeBs function returns an…
mushroom
  • 6,201
  • 5
  • 36
  • 63
-1
votes
1 answer

Does using a library like cats make upgrading to dotty more or less difficult?

If I use cats in my scala project, would it make migrating to dotty easier or difficult? I'm not too sure of the ramifications of using a library like this and how hard it will be to eventually migrate over to dotty.
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
-1
votes
1 answer

Scala cats: problem with implicits when trying to use `===` syntax for `Eq` trait

Aloha! :) I'm not happy about running all the time to the stackoverflow forums to get some help with another piece of strangeness scala/cats has thrown at me. Problem is: There seems to be no really useful documentation, only some worthless - at…
-1
votes
2 answers

Match that the result of running a computation is Invalid in a for comprehension

I am inside a for comprehension where we compose multiple operations together. When each step is completed, I need to either throw an error using MonadError.raiseError or carry on to the next step if valid. def myFunc[F[_]: Monad](input:…
vamsiampolu
  • 6,328
  • 19
  • 82
  • 183
-1
votes
1 answer

Building a compiler for Free monad (Cats library)

I'm trying to get my head around monads and Cats. Following some examples (e.g.cats) I wrote the code like below. But can't figure out how to make compiler to do what I need and to compile, actually. import cats.Id import cats.free.Free import…
kikulikov
  • 2,512
  • 4
  • 29
  • 45
-2
votes
1 answer

Where is StateT in Cats?

I have in my sbt: "org.typelevel" %% "cats-core" % "2.0.0-M1", "org.typelevel" %% "cats-effect" % "1.3.1", "org.typelevel" %% "cats-free" % "2.0.0-M3" But can't import StateT in code. In what module is it? It's referred to here…
jakstack
  • 2,143
  • 3
  • 20
  • 37
-2
votes
1 answer

Why running unsafeRunSync() twice breaks RT

I have following application that I could not figure it out, why running it twice it breaks RT: val program = for { _ <- IO { println("Welcome to Scala! What's your name?") } _ <- IO { println(s"Well hello, foo") } } yield…
softshipper
  • 32,463
  • 51
  • 192
  • 400
-3
votes
1 answer

Do tagless algebra needs laws?

I read the wonderful blog from JOHN A DE GOES regarding to tagless final. In the section 5.Fake Abstraction, he has mentioned: Unfortunately, these operations satisfy no algebraic laws—none whatsoever! This means when we are writing polymorphic…
softshipper
  • 32,463
  • 51
  • 192
  • 400
1 2 3
61
62