scalaz Questions
1
Solved
I started out with something like this:
def nonEmpty[A] = (msg: String) => (a: Option[A]) => a.toSuccess(msg)
val postal: Option[String] = request.param("postal")
val country: Option[String...
Bilbrey asked 16/10, 2014 at 17:9
2
Solved
I am using scalaz validation, and have some code to validate products.
def validateProduct(product: Option[Product]): ValidationNel[String, Product] = ???
Given a list of products, I want to ge...
Experimental asked 16/10, 2014 at 0:0
1
Solved
Based on:
import shapeless._
case class Content(field: Int)
lens[Content] >> 'field
I am trying to make a lens-creating method, something along:
def makeLens[T <: Product](s: Symbol) ...
4
Solved
If I have a following method
def getMyList :\/[Throwable,List[\/[Throwable,Int]]] ={
....
}
how to flatten type of getMyList to \/[Throwable,List[Int]]
1
Solved
I'm reading this great article about dependency injection in scala with Reader monad.
The original example is working well, but I did a little bit change on the return types of the UserRepository...
Mclane asked 20/9, 2014 at 14:5
3
Solved
I'm writing a library to access web service through the API. I've defined simple class to represent API action
case class ApiAction[A](run: Credentials => Either[Error, A])
and some functions...
Forgotten asked 1/9, 2014 at 9:48
1
Recently, I've been playing with scalaz.iteratee and Play's iteratee. I think that iteratee is a great idea to provide modularity instead of the old imperative while loop -- the aim is to use a fun...
Penmanship asked 29/8, 2014 at 2:28
1
Solved
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...
Milone asked 24/8, 2014 at 2:6
1
Solved
I'm trying to reduce this code (scalaz 7.0.x, scala 2.10.x):
type Error[+A] = \/[String, A]
type Result[+A] = OptionT[Error, A]
into this:
type Result[+A] = OptionT[({ type λ[+α] = String \/ α ...
1
Solved
As seen here, map is defined
in a slightly funky way
For completeness' sake, here's the code:
implicit def FunctionFunctor[R] = new Functor[({type l[a] = R=>a})#l] {
def map[A, B](fa: R ...
3
A couple of weeks ago Dragisa Krsmanovic asked a question here about how to use the free monad in Scalaz 7 to avoid stack overflows in this situation (I've adapted his code a bit):
import scalaz....
Greywacke asked 10/6, 2014 at 22:18
2
Solved
I am trying to write the following function
def haltOnUserInput[O](process: Process[Task, O]): Process[Task, O]
which halts process when the user sends a line on stdin. In this scenario, it is o...
Flyboat asked 16/7, 2014 at 19:45
1
Solved
I'm currently porting some code from traditional Scala to Scalaz style.
It's fairly common through most of my code to use the Seq trait in my exposed API signatures rather than a concrete type (i....
2
Solved
following is a toy example to demonstrate real life legacy methods' shape weirdness and point of the question.
As you can see anotherFunc, after mapping over personList expands type to \/[Throwabl...
1
Solved
Can somebody give an example how to use ScalaZ Free monad ?
For example, if I have a simple State function and want to apply it 10,000 times, I'd get StackOverflowError:
def setS(i: Int) :State[L...
1
Here's my code. It permits to create typesafe MongoDB queries using Casbah
trait TypesafeQuery[ObjectType, BuildType] {
def build: BuildType
}
trait TypesafeMongoQuery[ObjectType] extends Type...
1
Solved
I'm trying to understand Monad Transformers in Scala by porting some examples from this tutorial by Dan Piponi: http://blog.sigfpe.com/2006/05/grok-haskell-monad-transformers.html
I did a couple o...
Hardfeatured asked 6/5, 2014 at 5:11
2
Solved
I know in Scala, you can do type ===>[A, B] = Map[A, B] and then you can use infix notation to define def foo: String ===> Int which is same as saying def foo: Map[String, Int]. Is there any ...
Shellishellie asked 28/4, 2014 at 6:22
2
What is the best way to update an element in a collection using lenses? For example:
case class Ingredient(name: String, quantity: Int)
case class Recipe(val ingredients: List[Ingredient])
If ...
Regurgitation asked 18/10, 2013 at 8:14
1
Solved
In Scala, for reading a text file and uploading it into an array, a common approach is
scala.io.Source.fromFile("file.txt").getLines.toArray
Especially for very large files, is there a faster ap...
Crudity asked 11/4, 2014 at 8:43
1
Solved
What is the best way to do this:
def reduce[A](x: Option[A], y: Option[A])(f: (A, A) => A): Option[A] =
(x, y) match {
case (Some(a), Some(b)) => Some(f(a, b))
case (None, None) => No...
Shoa asked 7/4, 2014 at 2:13
1
I am looking at disjunction type of scalaz and I noticed method ap
/** Apply a function in the environment of the right of this disjunction. */
def ap[AA >: A, C](f: => AA \/ (B => C)): (AA \/ ...
1
Solved
I am confused with Either, Try, and Validation of scalaz. None of them seems to do what I need. What I need is a simple monad Result[E, R] where E is an error type and R is an result type.
Eithe...
Algia asked 13/3, 2014 at 12:24
1
Solved
How I can do a for comprehension with the data of type Future[\/[String,Int]]
Here is a starting point, which doesn't compile.
import scala.concurrent.{ExecutionContext,future,Future}
import scal...
Maladroit asked 24/2, 2014 at 16:2
2
Solved
In the Scalaz trait Foldable we see the method foldMap with the following description
Map each element of the structure to a [[scalaz.Monoid]], and combine the results.
def foldMap[A,B](fa: F[...
© 2022 - 2024 — McMap. All rights reserved.