Questions tagged [scalaz7]

Scalaz provides type classes and purely functional data structures for Scala

102 questions
1
vote
1 answer

scalaz.syntax.monad._ brokes applicative syntax

I have some code which uses either applicative and monad syntax. The code looks like this: import scalaz._ import scalaz.syntax.applicative._ import scalaz.syntax.std.boolean._ import scalaz.syntax.traverse._ //import…
Aitor ATuin
  • 15
  • 1
  • 3
1
vote
1 answer

When using an EitherT[StateWithSomeFixedStateType, T, U], how do you do some state manipulation when a left is returned?

Say you have an EitherT that looks something like this: type StateListOfString[+T] = State[List[String], T] type MyEitherT = EitherT[StateListOfString, Int, Boolean] If you have a for-comprehension that could return a left: my computation = for { …
James Moore
  • 8,636
  • 5
  • 71
  • 90
1
vote
1 answer

global, default implicits in scalaz (scalaz7)

When I code using Scalaz I often encounter problems, that there is no implicit in scope. I think there should be some default implicits somwhere in vast package scalaz, but either I don't know where or there are not any. Suppose we want to show any…
pawel.panasewicz
  • 1,831
  • 16
  • 27
0
votes
1 answer

Unwrapping the value of an Identity monad

I have been playing a little bit with scalaz and I am stuck on a seemingly trivial issue. I was playing around with the Reader and Kliesli monads and found myself with something like this: val gr = Reader { (_: Int) + 1 } val a = gr(1) That…
Luis Sisamon
  • 101
  • 7
0
votes
1 answer

Lifting a function which takes implicit parameter using functor (Scalaz7)

Just started learning Scalaz. Here is my code trait Monoid[A] { def mappend(a1: A, a2: A): A def mzero: A } object Monoid { implicit val IntMonoid: Monoid[Int] = new Monoid[Int] { def mappend(a1: Int, a2: Int): Int = a1 + a2 …
xeonzion
  • 35
  • 8
0
votes
1 answer

Scala multiple generic parameter data structure typeclass instance

I'm using Scalaz as I'm loving a lot of aspects from Haskell's type class setup in the standard libraries. But exactly this is my current problem. I have a generic data structure with two generic parameters: case class Parser[T,A](f: T => (T,A)) In…
bash0r
  • 774
  • 6
  • 17
0
votes
1 answer

Scalaz.NonEmptyList vs Scala.List?

Can someone explain why should I use Scalaz's NonEmptyList over Scala's List? In a immutable application it does not make much sense to create an empty List So should I always use NonEmptyList in an immutable application ? Why else would I use…
user794783
  • 3,619
  • 7
  • 36
  • 58
0
votes
1 answer

Scalaz Writer Monad and filterM

I am working my way through learning scalaz and Learn You A Haskell For Greater Good and wonder how to translate the filterM example from LYAHFGG to Scala. fst $ runWriter $ filterM keepSmall [9,1,5,2,10,3] with keepSmall defined as keepSmall :: Int…
mjaskowski
  • 1,479
  • 1
  • 12
  • 16
0
votes
1 answer

Create a OptionT[Future, A] from a lower-kinded type

I'm pretty new to scalaz, and I'm trying to figure out to convert various types to monad transformers. I'm stuck on trying to convert a Int to a OptionT[Future, Int], or even to EitherT[Future, String, Int]. I found a bunch of tutorials/SO answers…
dcastro
  • 66,540
  • 21
  • 145
  • 155
0
votes
0 answers

Memory efficient stream traversal using the scalaz Traverse typeclass

I'm trying to traverse/sequence a large stream (e.g. scala.collection.immutable.Stream) using Scalaz' (version 7.1.2) Traverse typeclass, but I'm constantly running into a java.lang.OutOfMemoryError: GC overhead limit exceeded issue. My traversal…
Martin Studer
  • 2,213
  • 1
  • 18
  • 23
0
votes
1 answer

Testing if the static types of 2 definitions are equal

Let's say I come up with a combinator: def optional[M[_]: Applicative, A, B](fn: Kleisli[M, A, B]) = Kleisli[M, Option[A], Option[B]] { case Some(t) => fn(t).map(_.some) case None => Applicative[M].point(none[B]) } This combinator maps…
Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
0
votes
1 answer

underscore in expression

What does the underscore mean in below snipped. This is fragment of scalaz7 library: trait Apply[F[_]] extends Functor[F] { self => //... def ap[A, B](fa: => F[A])(f: => F[A => B]): F[B] //... def apF[A, B](f: => F[A => B]): F[A] => F[B] =…
pawel.panasewicz
  • 1,831
  • 16
  • 27
1 2 3 4 5 6
7