Questions tagged [scalaz7]

Scalaz provides type classes and purely functional data structures for Scala

102 questions
1
vote
2 answers

Merge maps in scalaz with a complex (double) operation

I am using a map to associate certain values with a tuple (Int, Double) where the int is the order they appeared and the double the number of times they show (it is not, but is clearer like this using int and double to distinguish) The tricky part…
Luis Sisamon
  • 101
  • 7
1
vote
0 answers

Monad IO catchAll operator behave

I´m learning the monad IO of scalaZ and I cannot understand how catchAll and catchSome operators works. I was expecting so see a behave like the onError or onErrorrResumeNext of RxJava, but instead is not catching the throwable, and it´s just…
paul
  • 12,873
  • 23
  • 91
  • 153
1
vote
1 answer

Traversing Scalaz Tree

I'm trying to understand the scalaz tree structure and am having some difficulty! First I've defined a tree: val tree: Tree[Int] = 1.node( 2.leaf, 3.node( 4.leaf, 5.leaf)) So far using TreeLoc I've worked…
d80tb7
  • 863
  • 2
  • 9
  • 20
1
vote
1 answer

Where is Scalaz Bind.bind implemented?

I am curious where the method scalaz.Bind.bind is implemented? Thanks trait Bind[F[_]] extends Apply[F] { self => //// /** Equivalent to `join(map(fa)(f))`. */ def bind[A, B](fa: F[A])(f: A => F[B]): F[B] ... I am looking at 7.3.0-SNAPSHOT…
thlim
  • 2,908
  • 3
  • 34
  • 57
1
vote
2 answers

scala lifting function having with a collection as argument

I have a class which accepts a function f: Option[Seq[Option[A]]] => Option[A]] case class Function[A](operator: Option[Seq[Option[A]]] => Option[A], name: String, arity: Int) What i would like is for the user of this class to be able to not have…
raul ferreira
  • 886
  • 7
  • 21
1
vote
1 answer

Applicative validation syntax scalaz + shapeless 2.0

I'm trying to convert this Applicative validation syntax example into Scalaz 7 + Shapeless 2.0 //for jupyter-scala kernel //classpath.add("org.scalaz" %% "scalaz-core" % "7.2.7") //classpath.add("com.chuusai" %% "shapeless" % "2.3.2") case class…
alphageek
  • 770
  • 4
  • 15
1
vote
1 answer

use scalaz's === for adt's

I have just started to learn scalaz from eugene's blog post. I am trying to use === in my code but it returns a compile error value === is not a member of object Red Here's is my code import scalaz._ sealed trait TrafficLight case object Red…
xeonzion
  • 35
  • 8
1
vote
1 answer

How to implement a Scalaz Applicative?

I have a customer type QueryResult which is type QueryResult[A] = A org.scalactic.Or One[Error] When doing multiple queries, I get a List[QueryResult[A]], but I want a QueryResult[List[A]]. I can implement a sequence method for Lists but I would…
Joost den Boer
  • 4,556
  • 4
  • 25
  • 39
1
vote
1 answer

scalaz Foldable compose

i have a next code val listOption: List[Option[Int]] = List(1.some, none, 2.some) i want to fold elements, i write the next code val result = listx.fold(0.some)((acc, el) => { (acc, el) match { case (Some(a), Some(b)) => Some(a + b) case…
lito
  • 989
  • 8
  • 21
1
vote
1 answer

Why awakeEvery was removed from scalaz-stream

I found that there is no more awakeEvery inside scalaz.stream.Process in modern scalaz-stream. How to run something with period then?
dk14
  • 22,206
  • 4
  • 51
  • 88
1
vote
1 answer

Trampolining scalaz' Monad.whileM_ to prevent stack overflow

I'm using scalaz' Monad.whileM_ to implement a while loop in a functional way as follows: object Main { import scalaz._ import Scalaz._ import scala.language.higherKinds case class IState(s: Int) type IStateT[A] = StateT[Id, IState,…
Martin Studer
  • 2,213
  • 1
  • 18
  • 23
1
vote
1 answer

Convert Vector to Tuple scala

Is it possible to convert a vector of heterogeneous vectors to list of Tuple3 in Scala i.e. Vector(Vector(1,"a","b"),Vector(2,"b","c")) to List(Tuple3(1,"a","b"),Tuple3(2,"b","c"))
user2780187
  • 677
  • 7
  • 16
1
vote
1 answer

append method from scalaz stream io cause infinite loop

I use this code from scalaz stream website, it is working with to method, but it failed when I try to use append, it looks like into an infinite loop and never finish. The reason I want to use append method is that I dont want to rewrite the file by…
Xiaohe Dong
  • 4,953
  • 6
  • 24
  • 53
1
vote
1 answer

Why scalaz Semigroup is not covariant?

Is their a simple raison why Scalaz SemiGroup is not covariant …
ouertani
  • 347
  • 3
  • 8
1
vote
1 answer

Processing multiple files in parallel with scalaz streams

I'm trying to use scalaz-stream to process multiple files simultaneously, applying a single function to each line in the files, across all the files. For concreteness, suppose I have a function that takes a list of strings def f(lines:…
ncreep
  • 473
  • 3
  • 11