This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| My problem is: | |
| I have a function getData[A](params ...): Task[List[A]] that return asynchronously data | |
| But this data is big so I cut the call in several step playing with params | |
| In term of API, I want expose a function stream[A]: Process[Task, A] | |
| I see Process.repeatEval & stream.async.unboundedQueue API from scalaz | |
| but I don't understand how to use it to produce this result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.concurrent.ExecutorService | |
| import play.api.libs.concurrent.Execution.Implicits.defaultContext | |
| import scala.concurrent.{Future, Promise} | |
| import scala.util.{Failure, Success} | |
| import scalaz.{-\/, \/-} | |
| import scalaz.concurrent.{Strategy, Task} | |
| import scalaz.Scalaz.ToEitherOps | |
| package object async { | |
| implicit class FutureOps[A](f: Future[A]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*test("sortWith") { | |
| val ns = // !!! SCROLL DOWN --- MORE TEST DATA BELOW !!! | |
| List( | |
| 1327986000000L, | |
| 1327986000000L, | |
| 1327986000000L, | |
| 1327986000000L, | |
| 1254283200000L, | |
| 1254283200000L, | |
| 1254283200000L, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package fr.perfimmo.hiring | |
| // Le code compile ^^ | |
| object FrontDev { | |
| val whoWeAre = PerformmanceImmo( | |
| companyName = "performmance immo", | |
| website = "http://www.performance-immo.com", | |
| areaField = "edition logiciel / administration de bien", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.scalatest.{Matchers, FunSuite} | |
| import scala.annotation.tailrec | |
| // https://www.youtube.com/watch?v=hzf3hTUKk8U | |
| // http://blog.richdougherty.com/2009/04/tail-calls-tailrec-and-trampolines.html | |
| class TrampolineTest extends FunSuite with Matchers { | |
| sealed trait Trampoline[A] { | |
| final def run: A = runImpl(this) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object MoanadT { | |
| import play.api.libs.concurrent.Execution.Implicits.defaultContext | |
| import scalaz.OptionT | |
| import scalaz.Scalaz.{ToIdOps, ToEitherOps} | |
| import scalaz.{\/, EitherT} | |
| import scalaz.std.scalaFuture._ | |
| def fOptionT[A](x: Future[Option[A]]): OptionT[Future,A] = OptionT[Future,A](x) | |
| def fEitherT[E,A](x: Future[E \/ A]) = EitherT[Future, E, A](x) | |
| def toEither[E, A](e: E)(x: OptionT[Future, A]): EitherT[Future, E, A] = x.fold(some => some.right[E], e.left[A]) |> fEitherT[E,A] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** In fact I try to write parametric Eventsourcing apply function | |
| * And which allow me to have a parametric function for CommandHandler[D] too. | |
| */ | |
| trait ApplyTo { | |
| def applyTo[E, S](startingState: S)(events: List[E])(implicit de: DomainEvent.Aux[E, S]): S = { | |
| events.foldLeft(startingState) { (currentState, event) => de.apply(currentState, event) } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SpikeTest2 extends FunSuite with Matchers with DurationTestTools { | |
| val boatPrice = Price(1D, false, 20D) | |
| test("classic algo") { | |
| val season = BoatSeason(TODAY.minusDays(150), TODAY.plusDays(150)) | |
| val specialPeriod = (0 to 50).map { i => SpecialPricePeriod(TODAY.plusDays(i), TODAY.plusDays(i).plusDays(2), i +1) }.toList | |
| val (time, _) = mesureTimeExecutionOf { ClassicAlgo.buildBookingDaysPrice(boatPrice, season, specialPeriod, TODAY, TODAY.plusDays(5)) } | |
| time shouldBeMinusThan (50 milliseconds) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object Test { | |
| val toto: Toto = ??? | |
| val indexTotoInES: Toto => Future[Try[String]] = ??? | |
| val insertToto: Toto => Future[Option[Toto]] = ??? | |
| toto |> saveAndIndex(indexTotoInES)(insertToto) // compile OK | |
| toto |> saveAndIndexAlias(indexTotoInES)(insertToto) // Don't compile with errors : | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "pi_idxreclamations":{ | |
| "mappings":{ | |
| "lineshifts":{ | |
| "properties":{ | |
| "agence":{ | |
| "properties":{ | |
| "adresse":{ | |
| "type":"string" | |
| }, | |
| "codePostal":{ |