scalaz7

Scalaz 7 - why using type alias results in ambigous typeclass resolution for Reader

喜欢而已 提交于 2019-12-11 03:08:31
问题 Code to test with: import scalaz.{Reader, Applicative} class ReaderInstanceTest { type IntReader[A] = Reader[Int, A] val a = Applicative[({type l[A] = Reader[Int, A]})#l] // fine val b = Applicative[IntReader] // ^ ambigous implicit values // both method kleisliMonadReader .. // and method kleisliIdMonadReader .. } Is this related to Scala's higher-order unification for type constructor inference ticket? If so (and even if not), could you describe what happens here in the a and b cases? Do

Scalaz unboxed tagged type not automatically unboxed

不羁的心 提交于 2019-12-10 16:53:29
问题 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 * mass according to the guide, should yield 40.0 , however, on Scala 2.11.2 I get: scala> 2 * mass <console>:17: error: overloaded method value * with alternatives: (x: Double)Double <and> (x: Float)Float <and> (x: Long)Long <and> (x: Int)Int <and> (x: Char)Int

How to fix sbt's [warn] Skipped generating '<exclusion/>' for dependency?

时间秒杀一切 提交于 2019-12-10 15:46:13
问题 When I run makePom in sbt I get: [warn] Skipped generating '<exclusion/>' for org.scalaz#*. Dependency exclusion should have both 'org' and 'module' to comply with Maven POM's schema. [warn] Skipped generating '<exclusion/>' for com.jolbox#*. Dependency exclusion should have both 'org' and 'module' to comply with Maven POM's schema. What's the easiest way to fix this problem so that the correct exclusions get generated? The following does not work - it breaks the scalaz exclusion rule - I

Scalaz 7 Iteratee to process large zip file (OutOfMemoryError)

随声附和 提交于 2019-12-09 18:20:25
问题 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 that inflates each ZipEntry into a File object. The signature looks like: def enumZipFile(f:File):EnumeratorT[IoExceptionOr[IO[File]], IO] I want to attach an IterateeT that will perform the long-running process on each file. I basically end up

Scalaz: how to compose a map lens with a value lens?

核能气质少年 提交于 2019-12-06 01:39:44
问题 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 modifying values in a map. My question is: if I have a lens for modifying type V , and a lens for a Map[K,V] , how can I compose them? I've been searching for a while for a good simple example, but there's still a dearth of examples in Scalaz. I'm interested in both Scalaz 6 and Scalaz 7 solutions.

Where is `sequence` in Scalaz7

北慕城南 提交于 2019-12-04 16:01:26
问题 I am learning Scalaz and I have a project that already makes use of Scalaz7. Following this question I would like to use the function sequence[T](l: List[Option[T]]): Option[List[T]] (not that it is hard to write it myself). But the aforementioned question mentions Scalaz6. Where to find the sequence function in Scalaz7? 回答1: It's defined in the scalaz.Traverse type class, where it looks like this: def sequence[G[_]:Applicative,A](fga: F[G[A]]): G[F[A]] = traversal[G].run[G[A], A](fga)(ga =>

Scalaz: how to compose a map lens with a value lens?

本小妞迷上赌 提交于 2019-12-04 06:21:17
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 modifying values in a map. My question is: if I have a lens for modifying type V , and a lens for a Map[K,V] , how can I compose them? I've been searching for a while for a good simple example, but there's still a dearth of examples in Scalaz. I'm interested in both Scalaz 6 and Scalaz 7 solutions. If the lens you're trying to compose with the map lens is a partial lens, you can just use compose :

“private[syntax]” in Scala

自闭症网瘾萝莉.ら 提交于 2019-12-04 05:32:06
问题 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 = F.show(self) final def shows: String = F.shows(self) final def print: Unit = Console.print(shows) final def println: Unit = Console.println(shows) //// } ^ Location: scalaz-series-7.3.x/core/src/main/scala/scalaz/syntax/ShowSyntax.scala 回答1: private[packageX]

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

蓝咒 提交于 2019-12-03 16:15:16
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 then been studying Shapeless and type level programming in general to try to come up with a solution that works on tuples of any size. This is what I'm starting out with: import scalaz._, Scalaz._, shapeless._, contrib.scalaz._, syntax.std.tuple._ type Va[A] = Validation[String, A] // only works on pairs of Va[_] def validate[Ret, In1, In2](params:

Where is `sequence` in Scalaz7

余生颓废 提交于 2019-12-03 10:01:46
I am learning Scalaz and I have a project that already makes use of Scalaz7. Following this question I would like to use the function sequence[T](l: List[Option[T]]): Option[List[T]] (not that it is hard to write it myself). But the aforementioned question mentions Scalaz6. Where to find the sequence function in Scalaz7? It's defined in the scalaz.Traverse type class, where it looks like this: def sequence[G[_]:Applicative,A](fga: F[G[A]]): G[F[A]] = traversal[G].run[G[A], A](fga)(ga => ga) scalaz.syntax.TraverseOps provides a version that gets pimped onto List , since List has a Traverse