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

Why does scala not infer the right type when wrapping EitherT?

Here's the code: // eventually will be an implicit class with extension methods class EitherTWrapper [L,R] (ei: EitherT[Future,L,R]) new EitherTWrapper(??? : EitherT[Future,Nothing,Boolean]) Fails to compile with: type mismatch; found :…
Alvaro Carrasco
  • 6,103
  • 16
  • 24
0
votes
1 answer

How do I know, which implicit that is needs?

I have a working code: final case class Services[F[_]](c: Client[F], fooUrl: String) (implicit cf: ConcurrentEffect[F]) { private val dsl = Http4sDsl[F] import dsl._ def routes: HttpRoutes[F] =…
softshipper
  • 32,463
  • 51
  • 192
  • 400
0
votes
0 answers

running fs2.Stream under the method's hood?

I'm just learning FP, so maybe i'm doing this completely wrong. Using cats, cats-effects, fs2, fs2-io. Following code takes takes port as an argument then creates Server Socket and Client Socket connected to 127.0.0.1 on given port. What I need this…
pool
  • 11
  • 1
  • 1
0
votes
1 answer

Convert a list of stream values to a stream of values with fs2

I would like to define a function with the following signature using fs2 Streams, cats EitherT and cats-effect IO. def list2Stream[A,B,F[_],S](vs: List[A], f: A => EitherT[IO,S,Stream[IO,B]] …
Labra
  • 1,412
  • 1
  • 13
  • 33
0
votes
1 answer

Implementing functor map for class-tagged arguments only

I have the following data structure: class MyDaSt[A]{ def map[B: ClassTag](f: A => B) = //... } I'd like to implement a Functor instance for to be able to use ad-hoc polymorphism. The obvious attempt would be as follows: implicit val…
Some Name
  • 8,555
  • 5
  • 27
  • 77
0
votes
1 answer

Cannot convert HList to tuple after Shapeless FoldRight

I'm trying to create a parser of CSV files using Scala into a case class and I'm trying to make it generic using Shapeless. I want my parser to allow the user to specify an extraction function extract: CsvRow => String rather than having a a 1-to-1…
ColOfAbRiX
  • 1,039
  • 1
  • 13
  • 27
0
votes
1 answer

Scala Future/Option for comprehension issues

I am trying to write a function that reads from a repository (which returns F[Option[Entry]] where F is a future) and then converts it to F[Option[Element]]. The function convert() takes a Seq[Entry] and returns ValidatedNel[LoadError,…
0
votes
2 answers

Scala - how to make generic decoder in circe?

I have two similar functions which have different return types: override def getUsers(uri: Uri): F[Either[CodecException, List[User]]] = for { response <- retrieveDataFromClient(uri) result <- Sync[F].delay(response) } yield…
Developus
  • 1,400
  • 2
  • 14
  • 50
0
votes
1 answer

Scala - how to refactor code in functional style

I have created two similar methods: override def getUsers(organization: String, params: String): F[Either[CodecException, List[Users]]] = for { resp <- getUsersFromClient(organization, params) result <- Sync[F].delay(resp) } yield result …
Developus
  • 1,400
  • 2
  • 14
  • 50
0
votes
1 answer

Scala - how to get data from IO[HttpResponse] in Hammock?

I have a simple methods: def retrieveRepositories(url: String, params: String): IO[HttpResponse] = Hammock.getWithOpts(uri"$url", createOpts).exec[IO] Which is a http client. and json decoder: implicit def decodeResponseEntity(response:…
Developus
  • 1,400
  • 2
  • 14
  • 50
0
votes
1 answer

Scala - how to use foreach loop in for comprehension block?

I have a simple code: override def createContributorsList(url: String, params: String): F[List[Contributor]] = getContributorsFromClient(url, params).fold[List[Contributor]](_ => List(), res => res) override def createReposList(organization:…
Developus
  • 1,400
  • 2
  • 14
  • 50
0
votes
0 answers

Scala, unsafeRunSync - why it needs to be call every time?

I have a strange problem. I created two methods, which return Lists: override def createContributorsList(url: String, params: String): F[List[Contributor]] = getContributorsFromClient(url, params).fold[List[Contributor]](_ => List(), res =>…
Developus
  • 1,400
  • 2
  • 14
  • 50
0
votes
1 answer

Scala, Hammock - retrieve http response headers and convert JSON to custom object

I have created a simple program which use Hammock(https://github.com/pepegar/hammock) and now I would like to get response from github API with reposne's headers. I created a code like this: object GitHttpClient extends App { implicit val decoder…
Developus
  • 1,400
  • 2
  • 14
  • 50
0
votes
1 answer

Stop long running process on a Resource

I have a resource which runs a potentially long blocking operation. In the real code, it's a ZeroMQ routine that waits for the next message (not too dissimilar to the example code here), but in this example, I've created a dummy loop that only…
Cesar Pantoja
  • 173
  • 3
  • 11
0
votes
1 answer

Scala Kittens: implicit Sequencer value doesn't seem to work with context bound syntax

In my understanding the following two functions and their calls should be identical: def f1[L1 <: HList, L2](xs: L1)(implicit sequencer: Sequencer.Aux[L1, Option, L2]) { println(xs.sequence) } def f2[L1 <: HList : Sequencer.Aux[*, Option, L2],…
mrArkwright
  • 254
  • 2
  • 10