scalaz Questions
1
Solved
scalaz.Validation is said to be more powerful than the Try monad, because it can accumulate errors.
Are there any occasions where you might choose Try over scalaz.Validation or scalaz.\/ ?
Sneaking asked 9/2, 2014 at 19:57
1
Solved
I am trying to use >=> (Kleisli arrow) in Scala. As I understand, it composes functions returning monads. Now I am trying it as follows:
scala> val f = {i:Int => Some(i + 1)}
f: Int => Some...
2
Solved
I have a function that looks like this:
def emulate: (Cpu => Cpu) => (Cpu => Cpu) = render => {
handleOpcode andThen
handleTimers andThen
handleInput andThen
debug andThen
render
...
2
Suppose I was dealing with a simple colon-delimited text protocol that looked something like:
Event:005003:information:2013 12 06 12 37 55:n3.swmml20861:1:Full client swmml20861 registered [entry=...
2
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 ...
Marasmus asked 24/12, 2013 at 7:5
2
Solved
1
Solved
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 possib...
1
Scalaz offers a nice abstraction over stateful computations: The ST monad.
The ST monad allows capturing a side-effecting computation in a functional form.
In Haskell, I suppose, using such a mon...
1
Background
As noted in this question, I'm using Scalaz 7 iteratees to process a large (i.e., unbounded) stream of data in constant heap space.
My code looks like this:
type ErrorOrT[M[+_], A] = ...
0
I've been using Scalaz 7 iteratees to process a large (i.e., unbounded) stream of data in constant heap space.
In code, it looks something like this:
type ErrorOrT[M[+_], A] = EitherT[M, Throwab...
Leathaleather asked 27/9, 2013 at 20:48
1
Solved
There's an example of a Scalaz map lens here: Dan Burton calls it containsKey, and it's inspired by the Edward Kmett talk. There is also something called mapVPLens in Scalaz 7 which is useful for m...
Whang asked 16/9, 2013 at 18:49
1
Solved
I was just playing around a bit with ST in scalaz and came to the point, where I wanted to use the contents of a traversable type to modify my STRef. In Haskell I could do that as follows (taken fr...
Danica asked 15/8, 2013 at 14:58
1
Solved
Introduction
I use Scalaz 7's iteratees in a number of projects, primarily for processing large-ish files. I'd like to start switching to Scalaz streams, which are designed to replace the iteratee...
Frieda asked 7/8, 2013 at 19:33
2
Solved
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 (s...
Yetty asked 24/7, 2013 at 21:46
1
Solved
I'm trying to use Scalaz 7 Validation in my app. However, I'm having an issue getting the |@| applicative functor to coalesce my failures. Here's the code I have:
type ValidationResult = Validatio...
Durrell asked 17/7, 2013 at 23:15
2
Solved
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 all...
Corset asked 2/7, 2013 at 5:43
1
Solved
I have the following code that uses the Reader monad for configuration and also has to deal with IO[Option[String]] and I've ended up with code that stair-steps in my encode function.
How can I fo...
Gigantean asked 12/6, 2013 at 9:33
4
I have the following use case which occurs often in my code:
A Collection[A]
An implicit conversion A to B
and I want to obtain a collection of B. I can use implicitly like the following:
cas...
1
Solved
I have 19 strings that need to be validated into various types. When all validate successfully, I would like to instantiate a class that represents a row of a spreadsheet (where the columns do not ...
Cracy asked 5/6, 2013 at 1:57
1
Solved
Last night in responding to this question, I noticed the following:
scala> val foo: Option[Set[Int]] = Some(Set(1, 2, 3))
foo: Option[Set[Int]] = Some(Set(1, 2, 3))
scala> import scalaz._, ...
3
Solved
I occasionally hit code like this:
val things : List[A \/ B] = ???
val (as, bs) : (List[A], List[B]) = ??? //insert something to do this
or in my current case I want Map[A, B \/ C] => (Map[A,...
1
Solved
It seems to me that Scalaz' NonEmptyList has a monad instance, so a monad transformer for it (a bit similar to ListT) should be possible. Is that correct?
If so, is there one out there? (I couldn'...
Matterhorn asked 7/5, 2013 at 11:40
1
Solved
I'm struggling with understanding monad stacks and monad transformers with Scalaz7. I feel I'm pretty close to the answer but just can't get my head around a particular step.
The following code lo...
Hotel asked 20/5, 2013 at 21:6
2
Solved
Is there any way to use scalaz by simple scala command in the terminal, without creating sbt project?
1
Solved
The definition of the scalaz's option monoid is as follows:
implicit def optionMonoid[A: Semigroup]: Monoid[Option[A]] = new Monoid[Option[A]] {
def append(f1: Option[A], f2: => Option[A]) = (...
© 2022 - 2024 — McMap. All rights reserved.