Questions tagged [scalaz]

Scalaz provides type classes and purely functional data structures for Scala

Scalaz is a Scala library for functional programming.

It provides purely functional data structures to complement those from the Scala standard library. It defines a set of foundational type classes (e.g. Functor, Applicative, Monad) and corresponding instances for a large number of data structures.

More information is available on the Scalaz Project page

It is released under the BSD (open source) license.

1048 questions
0
votes
0 answers

akka serializer of scalaz.NonEmptyList (java.io.NotSerializableException)

Does any have an implementation of a serializer to resolve this problem, or know of any pleasing work arounds? I found this https://groups.google.com/forum/#!topic/scalaz/Dkvi3d-D7S4 Which suggests a future marking of NonEmptyList to serializable…
J Pullar
  • 1,915
  • 2
  • 18
  • 30
0
votes
1 answer

Short circuiting a list of functions returns \/

So I have an expensive method with this signature def func(param: Int): \/[String, Int] I am trying to loop over a list of params and returns \/[String, List[Int]] but stop the loop whenever the method returns -\/. I come up with this: scala> def…
Chikei
  • 2,104
  • 1
  • 17
  • 21
0
votes
0 answers

combining session with an another API using slick

moduel1 has a def save(model: MyModel) : Future[\/[Errs, MyModel] ] = async{ db.withSession{ ...... } } module1 has a REST endpoint which will let users persist MyModel coming in from the caller (web app in this case) so save() will have to…
Vikas Pandya
  • 1,998
  • 1
  • 15
  • 32
0
votes
1 answer

ActionBuilder to accept IO[Result] instead of Future[Result]

I wrote a small example to use the IO monad from scalaz within the play framework. The example below works as expected: object IOAction { def apply(action:IO[Result]):Result = action.unsafePerformIO } class ExampleController extends Controller…
user3459840
  • 125
  • 8
0
votes
1 answer

context bound of scalar.Coyoneda.liftTF

Finished watching thought-provoking video "Composable application architecture with reasonably priced monads" from Rúnar Bjarnason, I started to write the examples provided in the video in Scalaz. I am having a little surprise when implementing the…
Sheng
  • 1,697
  • 4
  • 19
  • 33
0
votes
1 answer

XML unescaping with Zipper in Scala

Suppose I need to unescape XML escaped characters in a given string: e.g. I need to replace & with &, " with ", < with < etc. I would prefer a purely functional solution. Does it make sense to do it with scalaz.Zipper ? Zipper allows…
Michael
  • 41,026
  • 70
  • 193
  • 341
0
votes
1 answer

Restrict method of a trait with constraint on abstract type member using implicits?

I am in the situation below: import scalaz.Leibniz._ trait Exp[T, C] { def &&(that: Exp[T, C])(implicit evT: T === Boolean) = LogicalAnd(this, that) def &&(that: Exp[T, C])(implicit evT: T === Int) = BitwiseAnd(this, that) } case class…
remi
  • 566
  • 3
  • 13
0
votes
1 answer

Type resolution with higher kinded types and implicits

I am trying to write a Value Class to add functionality to anything that implements Seq[_] and allow it to make batch calls that return a Future[_] (specifically, I am using it to make batch REST calls). final class BatchedList[A, C[X] <:…
Jeff
  • 237
  • 2
  • 6
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

ScalaZ: what is "type Tagged[T] = {type Tag = T}"?

I started to read scalaz's source code. package object scalaz { import Id._ implicit val idInstance: Traverse1[Id] with Each[Id] with Monad[Id] with Comonad[Id] with Distributive[Id] with Zip[Id] with Unzip[Id] with Align[Id] with Cozip[Id] =…
jhegedus
  • 20,244
  • 16
  • 99
  • 167
0
votes
2 answers

separate two lists by difference in elements in them

If I have val incomingIds : List[Int] = .... val existingIds : List[Int] = //this makes db calls and find existing records (only interested in returning ids) Now next I want to compare incomingIds with existingIds in a following way say I have val…
user2066049
  • 1,371
  • 1
  • 12
  • 26
0
votes
2 answers

Liftweb return response from scalaz

I have a next code, which return: import com.twitter.util.{Future, NonFatal} import net.liftweb.http.{LiftResponse, OkResponse} def service(str: Strign) : Future[ValidationNel[String, LiftResponse]] = { if str == "ok" …
lito
  • 989
  • 8
  • 21
0
votes
1 answer

How to convert a Map to Traverse

Is there a way to convert a Map to a Traverse ? The aim is to call map.traverseS(…). Error is :16: error: value traverseS is not a member of scala.collection.immutable.Map[String,Int]
Yann Moisan
  • 8,161
  • 8
  • 47
  • 91
0
votes
2 answers

How to traverse with scalaz

I've tried to simplify a real code but not to much. Given the following input, implementation of f and g are just for examples, real one are more complicated scala> val m = Map("a" -> 1, "b" -> 2, "c" -> 3, "d" -> 4) m:…
Yann Moisan
  • 8,161
  • 8
  • 47
  • 91
0
votes
1 answer

throw Throwable within \/.fromTryCatch - and align method types correctly

I have following existing method: def test: \/[Throwable, Person] = { \/.fromTryCatch { //existing logic has potential to throw exception (from calls like .toInt) etc //now via following for comprehension want to combine Throwable with…
Vikas Pandya
  • 1,998
  • 1
  • 15
  • 32