github.com/suls • Husband of one, father of two • Living and working in beautiful Sendai, Japan • Speaking: Swiss German, English, a bit Japanese & French
why you would want to use scalaz-stream • the basic building blocks of scalaz-stream • iteratively built a small report generation ϨϙʔτੜϓϩάϥϜͷྫΛ௨ͯ͡ scalaz-stream ͷ͍Ͳ͜ΖͱجຊతͳߏཁૉΛղઆ
user input, ..) • transforms data • produces data (..) • runs once, repeatedly or infinitely .. then scalaz-streams might be worth looking at. σʔλΛফඅɾมɾੜ͢ΔϓϩάϥϜΛ࡞ΔͳΒ scalaz-stream Λߟྀ͢ΔՁ͕͋Δ
computations using Process • Then we “run” it to get its effect • And finally we “run” the effect Process ΛͬͯҰ࿈ͷܭࢉΛ४උ࣮ͯ͠ߦ (run) ͠ ͦΕʹΑͬͯಘͨ࡞༻Λ࠷ऴతʹ࣮ߦ (run) ͢Δ
produce a value until a Sink requests one • Back-pressure for free • Being lazy allows us to create infinite Processes • Process can be executed multiple times scalaz-stream ϓϧܕͳͷͰɺແݶ Process Λ࡞ͬͨΓɺ Process ΛԿ࣮ߦͨ͠ΓͰ͖Δ
sequence of actions • scalaz-stream provides primitves for non- deterministic operations • merge operator to combine n Process • async.boundedQueue to fan out Process ܾఆੑͷΞΫγϣϯྻ͕ͩ scalaz-stream ඇܾఆੑԋࢉఏڙ͢Δ
q.close) p : Process[Task, Unit] > val q = async.boundedQueue[String](1) q: sz.s.async.mutable.Queue[String] > val r = q.dequeue to io.stdOutLines r: Process[Task, Unit] ϑΝϯΞτͷͨΊͷඇಉظ༗ݶΩϡʔ
why you would want to use scalaz-stream • the basic building blocks of scalaz-stream • iteratively built a small report generation ͜ΕͰ͋ͳͨ scalaz-stream Λ͍ͨ͘ͳͬͨͣ