Scalaz provides type classes and purely functional data structures for Scala
Questions tagged [scalaz7]
102 questions
29
votes
2 answers
Why isn't Validation a Monad?
an example use case:
def div2(i: Int): Validation[String, Int] =
if (i%2 == 0) Validation.success(i/2)
else Validation.failure("odd")
def div4(i: Int) = for {
a <- div2(i)
b <- div2(a)
} yield b
error: Unable to unapply type…

Chris
- 1,094
- 1
- 11
- 26
24
votes
1 answer
Why is List a Semigroup but Seq is not?
I'm fairly new to scalaz and I am trying to figure out why the following code works:
import scalaz._
import Scalaz._
scala> Map[String,List[String]]() |+| Map[String,List[String]]()
res3: scala.collection.immutable.Map[String,List[String]] =…

coltfred
- 1,470
- 9
- 17
24
votes
4 answers
Finding my way through Scalaz
Possible Duplicate:
Good scalaz introduction
I would like to learn more about Scalaz, possibly using Scalaz7 to be avoid rewiring my brain once it is declared stable. My problem is that Scalaz contains a lot of functionality. While most of it is…

Andrea
- 20,253
- 23
- 114
- 183
21
votes
1 answer
Lifting a bijection into a functor
Maybe I'm missing something obvious, but I'm trying to clean up some boilerplate in a project that uses Scalaz 7, and I'm not finding one particular puzzle piece that seems pretty simple and possibly useful.
Suppose we have a bijection between two…

Travis Brown
- 138,631
- 12
- 375
- 680
18
votes
4 answers
A little help on understanding Scalaz Future and Task
I'm trying to understand the idea and purpose behind scalaz concurrent package, primarily Future and Task classes, but when using them in some application, it's now far from simple sequential analog, whereas scala.concurrent.Future, works more then…
user1078671
18
votes
2 answers
Combining EitherT and Future
I have an app that does a lot of calls to different backend systems, and hoping to use for-comprehensions to simplify the process flow across the backend systems.
I'm looking to combine EitherT (scalaz) and Future (scala 2.10) so I can capture the…

Mark Sivill
- 825
- 1
- 9
- 18
18
votes
1 answer
Where is `sequence` in Scalaz7
I am learning Scalaz and I have a project that already makes use of Scalaz7. Following this question I would like to use the function
sequence[T](l: List[Option[T]]): Option[List[T]]
(not that it is hard to write it myself). But the aforementioned…

Andrea
- 20,253
- 23
- 114
- 183
12
votes
2 answers
Convert scala 2.10 future to scalaz.concurrent.Future // Task
did anybody come to piece of code how to properly convert scala's Future (2.10) to new scalaz7 future ? I know hot to convert scalaz future via scala Promise to scala Future, but not sure how to do it properly around
For example
import…

Pavel Chlupacek
- 864
- 5
- 8
12
votes
1 answer
Managing imports in Scalaz7
I am using scalaz7 in a project and sometimes I run into issues with imports. The simplest way get started is
import scalaz._
import Scalaz._
but sometimes this can lead to conflicts. What I have been doing until now the following slightly painful…

Andrea
- 20,253
- 23
- 114
- 183
11
votes
2 answers
Monadic fold with State monad in constant space (heap and stack)?
Is it possible to perform a fold in the State monad in constant stack and heap space? Or is a different functional technique a better fit to my problem?
The next sections describe the problem and a motivating use case. I'm using Scala, but solutions…

David B.
- 5,700
- 5
- 31
- 52
11
votes
1 answer
How to use IO with Scalaz7 Iteratees without overflowing the stack?
Consider this code (taken from here and modified to use bytes rather than lines of characters).
import java.io.{ File, InputStream, BufferedInputStream, FileInputStream }
import scalaz._, Scalaz._, effect._, iteratee.{ Iteratee => I, _ }
import…

Redattack34
- 125
- 4
9
votes
1 answer
|+| is a semigroup, why it needs a monoid implicit resolution
The aim of Semigroup is to make sure Associativity and closure
The aim of monoid is based on Semigroup and provide additional Identity.
When I use |+| semigroup appender, why I have define implicit monoid not implicit semigroup
Here is the code I am…

Xiaohe Dong
- 4,953
- 6
- 24
- 53
9
votes
2 answers
How to return a tuple inside an EitherT
I'm using Scalaz 7's EitherT to construct for-comprehensions that blend State and \/. So far so good; I get something that's basically:
State[MyStateType, MyLeftType \/ MyRightType]
and that allows me to build for-comprehensions that have nice…

James Moore
- 8,636
- 5
- 71
- 90
9
votes
1 answer
how does work scalaz.Validation loopSuccess and loopFailure
Could someone explain with real world examples how does work below methods of scalaz.Validation?
I mean loopSuccess and loopFailure.
Snippetes from source code (scalaz7):
scalaz.Validation:
/** Spin in tail-position on the success value of this…

pawel.panasewicz
- 1,831
- 16
- 27
8
votes
1 answer
How to solve type mismatch when compiler finds Serializable instead of the match type?
I have have the following parser to parse arithmetic expressions containing Float and RDD :
import scalaz._
import Scalaz._
def term2: Parser[List[\/[Float, RDD[(Int,Array[Float])]]]] = rep(factor2)
def factor2: Parser[\/[Float,…

Mahsa
- 1,502
- 7
- 18
- 40