Questions tagged [scalaz7]

Scalaz provides type classes and purely functional data structures for Scala

102 questions
5
votes
2 answers

scalaz 7 equivalent of `<|*|>` from scalaz 6

In Nick Partridge's presentation on deriving scalaz, based on an older version of scalaz, he introduces validations using a function: def even(x: Int): Validation[NonEmptyList[String], Int] = if (x % 2 == 0) x.success else { s"not even:…
Joe Kearney
  • 7,397
  • 6
  • 34
  • 45
5
votes
1 answer

How to use a Monad Transformer when Disjunction is the outermost container?

val vLInts = (1 to 10).toList.right[String] for { i <- ListT(vLints) _ = println(i) } yield i //error: no type parameters for method apply:(underlying: M[List[A]])scalaz.ListT[M,A] in object ListT exist so that it can be applied to arguments…
jordan3
  • 877
  • 5
  • 13
5
votes
0 answers

Implicit conversion from Traversable to Foldable in Scalaz 7

Where is the implicit conversion from a scala.collection.Traversable[A] to a scalaz.Foldable[A] defined in Scalaz 7.x? The standard import import scalaz._ import Scalaz._ does not include it. There used to be an implicit def…
David B.
  • 5,700
  • 5
  • 31
  • 52
5
votes
2 answers

Scalaz Tree to JSON

I'm currently trying to use the Tree class to build a tree-strucuture from a database query. Afterwards I want to convert it to a json object (with playframework api). Some examples or a bit more documentation for the Tree class would be awesome. I…
Muki
  • 3,513
  • 3
  • 27
  • 50
5
votes
1 answer

Type class for uniting unrelated failure cases in my Scalaz disjunctions

I have a for comprehension over Scalaz disjunctions. The left types on these can be different types of error case classes from other libraries. For example, one failure case can be due to an HTTP timeout while another can represent a Json parsing…
Mad Dog
  • 583
  • 4
  • 18
5
votes
3 answers

Scalaz 7 Iteratee to process large zip file (OutOfMemoryError)

I'm trying to use the scalaz iteratee package to process a large zip file in constant space. I have a long-running process I need to perform on each file in the zip file. Those processes can (and should) be run in parallel. I created an EnumeratorT…
RJ Regenold
  • 1,748
  • 13
  • 17
5
votes
1 answer

Simple control flow in scalaz effect

Take this simple bit of code: var line = ""; do { println("Please enter a non-empty line: ") line = readLine() } while (line.isEmpty()) println("You entered a non-empty line: " + line) It's definitely not particularly elegant, especially with…
Heptic
  • 3,076
  • 4
  • 30
  • 51
4
votes
1 answer

Chaining a number of transitions with the state Monad

I am starting to use the state monad to clean up my code. I have got it working for my problem where I process a transaction called CDR and modify the state accordingly. It is working perfectly fine for individual transactions, using this function…
Luis Sisamon
  • 101
  • 7
4
votes
1 answer

"private[syntax]" in Scala

What is this "private[syntax]" language feature? /** Wraps a value `self` and provides methods related to `Show` */ final class ShowOps[F] private[syntax](val self: F)(implicit val F: Show[F]) extends Ops[F] { //// final def show: Cord =…
Michael Lafayette
  • 2,972
  • 3
  • 20
  • 54
4
votes
2 answers

Generic transform/fold/map over tuple/hlist containing some F[_]

I recently asked Map and reduce/fold over HList of scalaz.Validation and got a great answer as to how to transform a fixed sized tuple of Va[T] (which is an alias for scalaz.Validation[String, T]) into a scalaz.ValidationNel[String, T]. I've since…
Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
4
votes
1 answer

Scalaz unboxed tagged type not automatically unboxed

Reading http://eed3si9n.com/learning-scalaz/Tagged+type.html and trying out the sample code: import scalaz._; import Scalaz._ sealed trait KiloGram def KiloGram[A](a: A): A @@ KiloGram = Tag[A, KiloGram](a) val mass = KiloGram(20.0) 2 *…
Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
4
votes
1 answer

How to exit a program properly when using Scalaz Futures and the timed function

This works as expected: object Planexecutor extends App { import scalaz.concurrent.Future import scala.concurrent.duration._ val f = Future.apply(longComputation) val result = f.run println(result) } This does not: object…
jedesah
  • 2,983
  • 2
  • 17
  • 29
4
votes
1 answer

Iso macro in Scala

If I want to implicitly convert two objects from one to another, is there anyway to do this using something like an Iso macro? For example, if I have this: implicit def listToMap[A, B](l: List[(A, B)]): Map[A, B] = l.toMap implicit def mapToList[A,…
pathikrit
  • 32,469
  • 37
  • 142
  • 221
4
votes
1 answer

collapsing \/[A,A] to A

In a web application, I've got an action that can fail in various different ways, or eventually succeed. In this context success and failure are represented by subclasses of SimpleResult (representing an HTTP response) I use the monadic operations…
Valentin Kasas
  • 203
  • 1
  • 6
4
votes
1 answer

Scala Implicit generators

If I have an implicit from A to B, how can I auto-get implicits from F[A] to F[B]? For example, if I have implicit toInt[A](l: List[A]) = l.size and now I want to have an implicit from (List[A], Int) to (Int, Int) which reuses the toInt implicit.…
pathikrit
  • 32,469
  • 37
  • 142
  • 221