scalaz Questions

2

Solved

I'm playing around with Scala(z) to learn functionnal programming. I have a value of type Future[List[Error \/ Double]] and want to transform it to something with the type Future[[List[Error] \/ ...
Thwack asked 30/8, 2016 at 12:14

1

Given a typeclass where instance selection should be performed based on the return type: case class Monoid[A](m0: A) // We only care about the zero here implicit def s[T] : Monoid[Set[T]] = Monoid...
Pekin asked 1/6, 2015 at 16:9

1

Solved

I'm trying to understand the following piece of code (from the Scalaz library): def kleisliIdApplicative[R]: Applicative[Kleisli[Id, R, ?]] = ... I'm assuming that a type of the form T[P0, ?] is...
Parsonage asked 27/7, 2016 at 17:23

1

I'm trying to stack monad transfromers of scalaz in a haskell way: statyReader :: (MonadReader Int m, MonadState Int m) => m Int scala: def statyReader[F[_]](implicit r: MonadReader[F, Int]...
Minstrelsy asked 21/7, 2016 at 16:10

2

Introduction Scala's Future (new in 2.10 and now 2.9.3) is an applicative functor, which means that if we have a traversable type F, we can take an F[A] and a function A => Future[B] and turn t...
Kries asked 10/8, 2013 at 15:58

1

Solved

With Scalaz, a function can be mapped over another function. When would I want to use map over andThen? Is there a clear advantage using map? Thanks For example, val f: Int => Int = (a) => ...
Shanda asked 2/7, 2016 at 9:42

1

The Free implementation in Haskell is: data Free f a = Pure a | Free (f (Free f a)) whereas, the implementation in Scalaz is: sealed abstract class Free[S[_], A] private case class Return[S[_]...
Armbrecht asked 10/6, 2016 at 7:27

0

For (a cut-down) example, class SemigroupOps[F] (val self: F)(val F: Semigroup[F]) extends Ops[F] { def |+|(other: => F): F = F.append(self, other) } F in this case is a variable so I'd expe...
Astrogate asked 23/5, 2016 at 7:47

2

In OOP it is good practice to talk to interfaces not to implementations. So, e.g., you write something like this (by Seq I mean scala.collection.immutable.Seq :)): // talk to the interface - good ...
Svetlanasvoboda asked 9/5, 2016 at 12:55

1

Solved

How to turn a List of Eithers to a Either of Lists, using MonadPlus.separate? In this answer the author claims this solution, but fails to provide the imports or complete example: If scalaz is ...
Ridenhour asked 27/4, 2016 at 0:59

1

Solved

Applicative functors are often mentioned as an alternative to monads when your computation steps are independent. One of their often-mentioned advantages is that you don't need transformers when yo...
Rolf asked 20/4, 2016 at 18:6

1

Solved

Having read the book Learn you a Haskell For Great Good, and the very helpful wiki book article Haskell Category Theory which helped me overcome the common category mistake of confusing category ob...
Fant asked 19/4, 2016 at 10:35

1

Solved

The goal is to implement different type classes (like Semigroup, Monad, Functor, etc.) provided by Scalaz for Spark's RDD (distributed collection). Unfortunately, I cannot make any of the type clas...
Thoth asked 17/4, 2016 at 4:15

1

Solved

I have two (or more) functions defined as: val functionM: String => Option[Int] = s => Some(s.length) val functionM2: Int => Option[String] = i => Some(i.toString) I also have some d...

1

Solved

I have the following situation, given two types MA and MB, I would like to be able to prove that they both not only have an Applicative but also that they both have the same underlying shape. I tri...
Moonlit asked 7/3, 2016 at 13:54

2

We can describe monad, as the computational context, and monad implementation exactly preserves the meaning of that context. For example Option - the context meaning is that the value might exist. ...
Aerator asked 4/3, 2016 at 9:30

3

Solved

I've found this pattern quite a few times in my code: if (doIt) object.callAMethod else object I'm wondering if there could be a syntactically more pleasing way to write the code above, espe...
Lyingin asked 5/9, 2011 at 23:36

1

Solved

I would like to create an RDD to collect the results of an iterative calculation . How can I use a loop (or any alternative) to replace the following code: import org.apache.spark.mllib.random.R...
Capstan asked 18/2, 2016 at 8:19

1

Solved

Suppose I want to aggregate data from 2 remote services, and serve response as fast as I can: def loadUser: Future[User] def loadData: Future[Data] case class Payload(user: User, data: Data) ...
Larina asked 1/2, 2016 at 22:46

1

Solved

Scalaz State monad's modify has the following signature: def modify[S](f: S => S): State[S, Unit] This allows the state to be replaced by state of the same type, which does not work well whe...
Boehmenism asked 19/1, 2016 at 7:30

4

Solved

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 analo...
Te asked 30/10, 2013 at 19:52

1

We used the WriterT monad transformer on Futures hoping to get more organized logs from an asynchronous application, but we ran into some trouble. If I compile the application below, I get the fol...
Ineluctable asked 31/12, 2015 at 16:42

3

I haven't seen many examples of the scalaz state monad. There is this example but it is hard to understand and there is only one other question on stack overflow it seems. I'm going to post a few ...
Lallygag asked 12/10, 2011 at 2:56

1

Solved

As I known, shapeless provides the HList (Heterogenous list) type which can include multiple types. Is it possible to fold HList? for example, // ref - Composable application architecture with re...
Pullet asked 28/11, 2015 at 12:40

2

Solved

I would like to implement my asynchronous processing with scalaz.concurrent.Task. I need a function (Task[A], Task[B]) => Task[(A, B)] to return a new task that works as follows: run Task[A] ...
Surplus asked 11/10, 2015 at 13:30

© 2022 - 2024 — McMap. All rights reserved.