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
1 answer

How to use scalaz's `Tagged Type` to replace my type alias?

I want to define objects as functions and depend it in other functions: type FetchPage = String => String type FindImages = String => List[String] object WillFetchPage extends FetchPage { def apply(url:String):String = /* get content of the url…
Freewind
  • 193,756
  • 157
  • 432
  • 708
0
votes
1 answer

Mysterious Scalaz NoClassDefFoundError and scalaz.InvariantFunctor errors

I have the following build.sbt, and am running Scala 2.10.4 with IntelliJ managing sbt, and refreshing the project based on the sbt build file. Everything was working fine, until i added scalaz-streams -- I cannot seem to be able to use…
flubba
  • 75
  • 1
  • 6
0
votes
1 answer

Scalaz + Jetty url not found

I am a little stuck with the book Scala in Action now on Chapter 7. There is an example application build in the book that uses Jetty Server and Scalaz. The point is that once the Jetty server is started and a GET request is sent to a specific url,…
Marin
  • 861
  • 1
  • 11
  • 27
0
votes
1 answer

Scalaz finding for a certain type in a NonEmptyList[MyType]

I have a validated type which I pass to a function and in that function, I pattern match for Success and Failure and in the Failure block, I would like to see from the NonEmptyList if there is a certain type and if yes, I would like to return true…
joesan
  • 13,963
  • 27
  • 95
  • 232
0
votes
1 answer

Scala iterate over a set of objects

I have a sealed trait which is implemented by 3 objects sealed trait MyTrait { ... } object A extends MyTrait { ... } object B extends MyTrait { ... } object C extends MyTrait { ... } I'm using Scalaz's validation mechanism wherein the apply…
joesan
  • 13,963
  • 27
  • 95
  • 232
0
votes
1 answer

Stream processing

Have a requirement that when user is uploading a file it should work in a following manner 1)File upload dialog (in browser) is presented to the user. User picks a file. 2) Application should load only first x number of records (e.g. lets say total…
user2066049
  • 1,371
  • 1
  • 12
  • 26
0
votes
0 answers

Semigroup-like thing where the append operation can fail

Suppose I have some type with an associative binary operation that feels a lot like append except that the operation may fail. For example, here's a wrapper for List[Int] that only allows us to "add" lists with the same length: case class Foo(xs:…
Travis Brown
  • 138,631
  • 12
  • 375
  • 680
0
votes
1 answer

Problems using Nothing bottom type while trying to create generic zeros for parametrized monoids

Here's my code. It permits to create typesafe MongoDB queries using Casbah trait TypesafeQuery[ObjectType, BuildType] { def build: BuildType } trait TypesafeMongoQuery[ObjectType] extends TypesafeQuery[ObjectType, DBObject] case class…
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
0
votes
3 answers

Refactor OO code to functional

Wanting to refactor this OO looking code that I just came across. author of the code says MySave class was created solely as a placeholder for keys and inserts maps. client of MySave class always creates new instance of MySave per every request…
user2066049
  • 1,371
  • 1
  • 12
  • 26
0
votes
1 answer

How to deal with multiple IO points in Scalaz and spray

A REST call uses spray.io. It validates the request in that call using various functions including one in the middle that queries a data store. If all is ok then it writes to said data store. In this situation there are up to 4 IO actions: HTTP…
shmish111
  • 3,697
  • 5
  • 30
  • 52
0
votes
1 answer

scalaz using reduceLeft for applicative builder

I am little confused about |@| magic in scalaz. Here is my code: def isThree(x: Int): Validation[NonEmptyList[String], Int] = if (x!= 3){("failed: %d" format x).wrapNel.failure} else {x.success} println((isThree(6) |@| isThree(7) |@| isThree(13) )…
Xiaohe Dong
  • 4,953
  • 6
  • 24
  • 53
0
votes
1 answer

Max subsequence sum in the array with no two adjacent elements in Scala

I am trying to solve a problem of calculating max subsequence sum of an array with no adjacent elements are part of that sum. For every element at ith index, i am checking max of i-2 and i-3 elements and adding ith element to that to get max so…
Rajeev
  • 4,762
  • 8
  • 41
  • 63
0
votes
0 answers

Why is Writer monad defined as WriterT in scalaz?

I noticed that some monads, e.g. Writer, are defined in scalaz as monad transformers of Identity monad. Why is that ?
Michael
  • 41,026
  • 70
  • 193
  • 341
0
votes
1 answer

Why does calling sumr on a stream with 50 tuples not complete

While investigating a bug today, I noticed that calling sumr on a stream with 50 (Int, Int) tuples never completes, but it does on a smaller stream. Calling .toList on the larger stream first completes as well. Is this the intended behavior when…
Ayush
  • 41,754
  • 51
  • 164
  • 239
0
votes
1 answer

EitherT with Reader generalizing over Reader input

A standard construct in my code is a function that returns a Reader[X,\/[A,B]] and I would like to use the Either portion in a for comprehension, so I have been trying to write a function which will convert a function (X) => \/[A,B] into…
Travis Stevens
  • 2,198
  • 2
  • 17
  • 25
1 2 3
69
70