3 ms·
Unfortunately, you also get Enumeratee.take(4) &>> Iteratee.fold[Byte, Int](0){ case (acc, b) => acc * 256 + (b & 0xFF) } It's a community thin
by fizx 10y ago
Unfortunately, you also get
Enumeratee.take(4) &>> Iteratee.fold[Byte, Int](0){
case (acc, b) => acc * 256 + (b & 0xFF)
}
It's a community thing, and much like Java suffered from excessive XML and patterns in the 200Xs, but is much better now, Scala has suffered from excessive operator noise, but it's getting better.
- harveywi 10y agoIt would be fun, at some point, to compile a list of onomatopoetic translations for the various Scala operators that are found in nature. For example: >>= "fffff...Pwip!" (the sound of monadic bind) |==> "TCHvvvvvv..." (lightsaber igniting) |@| "AAAAAAHHHH!" (Edvard Munch 1893 operator)
- merb 10y agoScala Dotty will maybe have some kind of @infix("+") def add so that if it should be used via a + b it needs the infix else it's only possible todo a.+(b) p.s. I banned scalaz and shapeless on my company so there aren't too much operator noises.
- whateveracct 10y agoDo you ban cats too and any library of similar ilk? Just wondering, do you have your own libraries that use some of the good stuff? I can't imagine living in a world where I'm banned from using... * Traverse (do you write specialized versions for the cross product of [List, Vector, etc] x [Option, Either, etc] ?) * Validation (how do you collect errors? mutable.Buffer?) * NonEmptyList (I've written my own NonEmptyVector that wasn't that hard to write. Do you do that or just assume nonempty and it works out for you?) * Unapply (maybe this doesn't apply to you because you never use HKT-generic typeclasses?) I'm genuinely curious as all of these tools get used by me and my coworkers literally every day and without them we'd be writing boilerplate or making unchecked assumptions by the seat of our pants.
- merb 10y ago* Cross Product is never needed by us. * Validation? Actually we are on HTTP so mostly a sealed trait structure is enough for us we barly use `Seq(ValidationError)` from Playframework (only class constructs that manually) * NonEmptyList - I never came across a palce where I needed NonEmptyList?! * never needed. Just keep in mind other languages don't have such abstractions as well (maybe haskell has, but I don't know haskell). Some people need these high level abstractions and it's fine if you use it but most things are just syntactic sugar. The only stupid thing is something like that: - Future[Option[A1]] - Future[Option[A2]] ... - Future[Option[AN]] and now I need a `case Some((a1, a2)) =>` without some magic you write a lot of boilerplate. So a Monad is really something that would be great and probably we will evaluate if we get to use cats. Edit: Code Snippet: val h = (for { ph <- OptionT(dbService.byId(id)) article <- OptionT(articleDao.by0A(ph.article)) } yield (ph, article)).map{ case (ph, article) => (ph.id, article.id) } h.value yes this is something why we consider cats.
- codygman 10y ago> * NonEmptyList - I never came across a palce where I needed NonEmptyList?! Do you ever check the length of a list before applying a computation or dispatch based on a result list?
- merb 10y agoBasically we sometimes do. But all of that code is basically coming from either the database where we need to construct a list (which could be empty). Or it's coming from the user. I guess we have something like 30 occurences of .isEmpty/.nonEmpty in one of our codebases