scalaz

    1热度

    2回答

    我想使用optionT,我的功能正在返回Future[Option[T]] 我的一个电话返回Future[Seq[T]],应该怎么处理这个案例? for { user <- OptionT(api.getUser(123)) company <- OptionT(api.getCompany(user.companyId)) employees <- api.getE

    2热度

    1回答

    在我的应用程序中,我有很多地方,我需要获取元组列表,groupBy通过元组的第一个元素并将其从其余元素中删除。例如,我有元组 (1, "Joe", "Account"), (1, "Tom", "Employer"), (2, "John", "Account"), and result should be Map(1 -> List(("Joe", "Account"), ("Joe", "Ac

    1热度

    1回答

    我要在理解中 val list: List[Int] = List(1,2,3) def f1(i: Int): Future[Boolean] = ??? def f2(i: Int): Future[List[Int]] = ??? 看着this answer 如果我包裹清单,未来ANS CONVER的F返回类型列出这工作得很好混合列表和期货 import scalaz._ impo

    0热度

    1回答

    有一个web应用程序在服务器上使用以下堆栈: akka-persistence/service-layer/akka-http(for REST) 问题是: 我怎样才能 - 以最优雅,最干燥的方式 - 确保只有那些用户可以执行服务层中有权这样做的功能(在给定的输入参数下)。 因此,例如,让我们简单的例子: getEntity(userID:UserID, ref:EntityID):Entity

    0热度

    1回答

    我遇到cats/monads /理解问题。 请考虑下面的代码片段: import cats._ import cats.implicits._ final case class My[T]() implicit val monadMy: Monad[My] = new Monad[My] { ... } // this compiles def test11[A, B](m: My[

    1热度

    3回答

    我有一个场景,我根据条件在scala中压缩两个列表。 它们可能不是按顺序排列的。什么是最好的方式来做到这一点? 我想将具有相同requestId的DirectRetailCM和DirectRetailCM分组为一个元组。 object Main extends App { case class SalesDoc(val id: Int, val name: String, val req

    4热度

    1回答

    我想能够使用scalaz的| @ |在我自己的应用函数上。 例子: val spread: Source[Yield] = (y2 |@| y1)(_ - _) 这是我的课 sealed abstract class Source[+A] { def map[B](f: A => B): Source[B] def unit[A](a: A): Source[A] d

    0热度

    1回答

    当我尝试使用Lens.lensu从scalaz.7.2.15,(我检查http://eed3si9n.com/learning-scalaz/Lens.html) case class Person(id: Int, name: String) val idLens: Person @> Int = Lens.lensu( (p, id) => p.copy(id = id),

    3热度

    1回答

    我试图在"scalaz-core"%"7.2.14" StateT monads的组合中创建某种failover行为。 的StateT单子环绕EitherT因此这是一个单子转换: type Error = String type ErrOrT[T] = Error \/ T type State[T] = StateT[ErrOrT, String, T] 使用这些类型的一切的伟大工程 -

    1热度

    1回答

    从来就一直看着单子变压器的一些例子有Cats,我试图重现那些Scalaz 在这里,我有一个为理解我第一次收到一个可选的,我flatMap与OptionalT,第二个函数返回员工的未来。 这里我的代码 //Attributes for this example sealed trait Employee { val id: String } final ca