Découverte d'algèbre, d'interpréteur par la création d'un DSL pour la base de données Aerospike. Le tout est implémenté dans le langage Scala avec un style fonctionnel.
This is an introduction to some data structures that are powered by the Scalaz 8 effect system which are a core part of ZIO, https://github.com/scalaz/scalaz-zio
IO, Ref, Promise and Queue are powerful data structures to build asynchronous and concurrent applications using purely functional approach in order to solve the hard problems of software development in a principled way, without compromises.
ZIO Schedule: Conquering Flakiness & Recurrence with Pure Functional ProgrammingJohn De Goes
As professional software engineers, sometimes messy details of the real world stand in the way of us delivering principled software. Flaky connections, unreliable services, and bulletproof job scheduling in the presence of non-determinism and failure all tricky problems that discourage us from writing principled software. Yet sometimes the shortcuts we take to solve these problems result in downtime for the business and sleepless nights for us.
In this brand-new presentation, created exclusively for Scala in the City, John A. De Goes will show how functional programming can help bring order to even the most chaotic systems. Using ZIO, a new zero-dependency Scala library for building massively scalable asynchronous and concurrent applications, John will demonstrate how functional programming leverages reified effects and algebras to solve the trickiest of reliability and scheduling problems in a principled, composable, flexible way.
Join John for an evening of fun and functional programming as you explore fresh ways of thinking about reliability and scheduling, and come out of the talk with valuable skills for using ZIO to solve the everyday problems you encounter at work.
Modern applications are concurrent, parallel, asynchronous, and synchronous; they utilize many different subsystems, including network systems, actor systems, distributed systems, and more. Across all these modes of computation and different subsystems, the one constant is failure. Errors happen everywhere, and taming their monstrous complexity in a way that helps developers write correct code and troubleshoot failures is one of the hardest challenges of modern application development.
In this presentation, created just for the Dublin Scala Meetup, John A. De Goes and Kai from 7mind.io will take attendees on a tour of error management in Scala, comparing and contrasting Scala's own Future type, and the ZIO effect type. You'll see how functional effects provide features that go way beyond Future: including unified errors across all modes of computation, powerful error operators, lossless error propagation, compiler-assisted error handling, and a stunning new feature for debugging, sponsored by Irish consultancy 7mind.io, will be unveiled exclusively at this presentation.
Come learn about how modern functional effect systems like ZIO provide compelling new solutions to the problems of everyday error management.
An introduction to functional programming with goEleanor McHugh
A crash course in functional programming concepts using Go. Heavy on code, light on theory.
You can find the examples at https://github.com/feyeleanor/intro_to_fp_in_go
Moore's Law may be dead, but CPUs acquire more cores every year. If you want to minimize response latency in your application, you need to use every last core - without wasting resources that would destroy performance and throughput. Traditional locks grind threads to a halt and are prone to deadlocks, and although actors provide a saner alternative, they compose poorly and are at best weakly-typed.
In this presentation, created exclusively for Scalar Conf, John reveals a new alternative to the horrors of traditional concurrency, directly comparing it to other leading approaches in Scala. Witness the beauty, simplicity, and power of declarative concurrency, as you discover how functional programming is the most practical solution to solving the tough challenges of concurrency.
This is an introduction to some data structures that are powered by the Scalaz 8 effect system which are a core part of ZIO, https://github.com/scalaz/scalaz-zio
IO, Ref, Promise and Queue are powerful data structures to build asynchronous and concurrent applications using purely functional approach in order to solve the hard problems of software development in a principled way, without compromises.
ZIO Schedule: Conquering Flakiness & Recurrence with Pure Functional ProgrammingJohn De Goes
As professional software engineers, sometimes messy details of the real world stand in the way of us delivering principled software. Flaky connections, unreliable services, and bulletproof job scheduling in the presence of non-determinism and failure all tricky problems that discourage us from writing principled software. Yet sometimes the shortcuts we take to solve these problems result in downtime for the business and sleepless nights for us.
In this brand-new presentation, created exclusively for Scala in the City, John A. De Goes will show how functional programming can help bring order to even the most chaotic systems. Using ZIO, a new zero-dependency Scala library for building massively scalable asynchronous and concurrent applications, John will demonstrate how functional programming leverages reified effects and algebras to solve the trickiest of reliability and scheduling problems in a principled, composable, flexible way.
Join John for an evening of fun and functional programming as you explore fresh ways of thinking about reliability and scheduling, and come out of the talk with valuable skills for using ZIO to solve the everyday problems you encounter at work.
Modern applications are concurrent, parallel, asynchronous, and synchronous; they utilize many different subsystems, including network systems, actor systems, distributed systems, and more. Across all these modes of computation and different subsystems, the one constant is failure. Errors happen everywhere, and taming their monstrous complexity in a way that helps developers write correct code and troubleshoot failures is one of the hardest challenges of modern application development.
In this presentation, created just for the Dublin Scala Meetup, John A. De Goes and Kai from 7mind.io will take attendees on a tour of error management in Scala, comparing and contrasting Scala's own Future type, and the ZIO effect type. You'll see how functional effects provide features that go way beyond Future: including unified errors across all modes of computation, powerful error operators, lossless error propagation, compiler-assisted error handling, and a stunning new feature for debugging, sponsored by Irish consultancy 7mind.io, will be unveiled exclusively at this presentation.
Come learn about how modern functional effect systems like ZIO provide compelling new solutions to the problems of everyday error management.
An introduction to functional programming with goEleanor McHugh
A crash course in functional programming concepts using Go. Heavy on code, light on theory.
You can find the examples at https://github.com/feyeleanor/intro_to_fp_in_go
Moore's Law may be dead, but CPUs acquire more cores every year. If you want to minimize response latency in your application, you need to use every last core - without wasting resources that would destroy performance and throughput. Traditional locks grind threads to a halt and are prone to deadlocks, and although actors provide a saner alternative, they compose poorly and are at best weakly-typed.
In this presentation, created exclusively for Scalar Conf, John reveals a new alternative to the horrors of traditional concurrency, directly comparing it to other leading approaches in Scala. Witness the beauty, simplicity, and power of declarative concurrency, as you discover how functional programming is the most practical solution to solving the tough challenges of concurrency.
Introduction to how to test our programs using imperative programming and functional programming with Tagless Final technique and how to make it simpler using ZIO. ZIO provides many features for concurrency and asynchronous programs. This presentation is about how to use ZIO environment to test your application.
Final tagless. The topic strikes fear into the hearts of Scala developers everywhere—and not without reason. Final tagless allows developers to build composable Domain Specific Languages (DSLs) that model interaction with the outside world. Programs written using the final tagless style can be tested deterministically and reasoned about at compile-time. Yet the technique requires confusing, compiler-choking higher-kinded types, like `F[_]`, and pervasive, non-inferable context bounds like `F[_]: Concurrent: Console: Logging`. Many have looked at final tagless and wondered if all the layers of complexity and ceremony are really worth the benefits.
In this presentation, John A. De Goes provides a gentle and accessible introduction to final tagless, explaining what it is and the problem it intends to solve. John shows that while final tagless is easier to use than free monads, the technique suffers from a litany of drawbacks that push developers away from functional programming in Scala. John then introduces a novel approach that shares some of the benefits of final tagless, but which is idiomatic Scala, easy to explain, doesn’t need any complex type machinery, provides flawless type inference, and works beautifully across Scala 2.x and Scala 3.
Come join John for an evening of fun as you learn how to write functional code in Scala that's easy to test and easy to reason about—all without the complexity of free monads or final tagless.
Mozilla が力を入れているゲームに関する活動をテクノロジの面からまとめています。各種 API、特にWeb Workers、Typed Arrayと asm.js、WebAssembly のような JavaScript の高速化手法について概観します。
This slide describes Mozilla's Web Game initiative from technological perspective. We can overview technologies for Web Game: Web Workers, Typed Array, asm.js and WebAssembly. Please refer Mozilla Developer Network (MDN) for each technologies' details.
ZIO: Powerful and Principled Functional Programming in ScalaWiem Zine Elabidine
This is an introduction of purely functional programming type safe abstractions that provide a variety of features for building asynchronous and concurrent applications data structures built on ZIO.
You'll learn by examples about the power of functional programming to solve the hard problems of software development in a principled, without compromises.
Side by Side - Scala and Java Adaptations of Martin Fowler’s Javascript Refac...Philip Schwarz
Java’s records, sealed interfaces and text blocks are catching up with Scala’s case classes, sealed traits and multiline strings
Judge for yourself in this quick IDE-based visual comparison
of the Scala and Java translations of Martin Fowler’s refactored Javascript code.
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Developer Experience i TypeScript. Najbardziej ikoniczne duoThe Software House
Wiktor Toporek: TypeScript bez wątpienia jest obecnie pewnym standardem wśród obecnych rozwiązań powstałych w JavaScripcie. Ale czy poza byciem dodatkiem który uzupełnia odrobinę dokumentacje i deklaruje kontrakt jakiego typu parametry przyjmują i zwracają np. funkcje jakiejś biblioteki, można wycisnąć z niego coś więcej? Podczas prezentacji wykorzystamy TypeScript do granic możliwości, używając zaawansowanych technik które sprawiają że interfejs naszego API będzie sam kierował używających go developerów na drogę poprawnego użycia, które jest zgodne z naszymi (twórców) założeniami, poprawiając tym samym ich doświadczenia.
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Introduction to how to test our programs using imperative programming and functional programming with Tagless Final technique and how to make it simpler using ZIO. ZIO provides many features for concurrency and asynchronous programs. This presentation is about how to use ZIO environment to test your application.
Final tagless. The topic strikes fear into the hearts of Scala developers everywhere—and not without reason. Final tagless allows developers to build composable Domain Specific Languages (DSLs) that model interaction with the outside world. Programs written using the final tagless style can be tested deterministically and reasoned about at compile-time. Yet the technique requires confusing, compiler-choking higher-kinded types, like `F[_]`, and pervasive, non-inferable context bounds like `F[_]: Concurrent: Console: Logging`. Many have looked at final tagless and wondered if all the layers of complexity and ceremony are really worth the benefits.
In this presentation, John A. De Goes provides a gentle and accessible introduction to final tagless, explaining what it is and the problem it intends to solve. John shows that while final tagless is easier to use than free monads, the technique suffers from a litany of drawbacks that push developers away from functional programming in Scala. John then introduces a novel approach that shares some of the benefits of final tagless, but which is idiomatic Scala, easy to explain, doesn’t need any complex type machinery, provides flawless type inference, and works beautifully across Scala 2.x and Scala 3.
Come join John for an evening of fun as you learn how to write functional code in Scala that's easy to test and easy to reason about—all without the complexity of free monads or final tagless.
Mozilla が力を入れているゲームに関する活動をテクノロジの面からまとめています。各種 API、特にWeb Workers、Typed Arrayと asm.js、WebAssembly のような JavaScript の高速化手法について概観します。
This slide describes Mozilla's Web Game initiative from technological perspective. We can overview technologies for Web Game: Web Workers, Typed Array, asm.js and WebAssembly. Please refer Mozilla Developer Network (MDN) for each technologies' details.
ZIO: Powerful and Principled Functional Programming in ScalaWiem Zine Elabidine
This is an introduction of purely functional programming type safe abstractions that provide a variety of features for building asynchronous and concurrent applications data structures built on ZIO.
You'll learn by examples about the power of functional programming to solve the hard problems of software development in a principled, without compromises.
Side by Side - Scala and Java Adaptations of Martin Fowler’s Javascript Refac...Philip Schwarz
Java’s records, sealed interfaces and text blocks are catching up with Scala’s case classes, sealed traits and multiline strings
Judge for yourself in this quick IDE-based visual comparison
of the Scala and Java translations of Martin Fowler’s refactored Javascript code.
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Developer Experience i TypeScript. Najbardziej ikoniczne duoThe Software House
Wiktor Toporek: TypeScript bez wątpienia jest obecnie pewnym standardem wśród obecnych rozwiązań powstałych w JavaScripcie. Ale czy poza byciem dodatkiem który uzupełnia odrobinę dokumentacje i deklaruje kontrakt jakiego typu parametry przyjmują i zwracają np. funkcje jakiejś biblioteki, można wycisnąć z niego coś więcej? Podczas prezentacji wykorzystamy TypeScript do granic możliwości, używając zaawansowanych technik które sprawiają że interfejs naszego API będzie sam kierował używających go developerów na drogę poprawnego użycia, które jest zgodne z naszymi (twórców) założeniami, poprawiając tym samym ich doświadczenia.
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
This talk will explore inference from the perspective of protocols and generics and is based off a series of blog posts I've written(foxinswift.com) on the topic. In the first part of my talk casting number types through inference. I'll then show you struct serialization example demonstrating inferring a type through a mapping function. My last example will take you through inferring an associatedtype on a barebones promise implementation and we'll use it to in the context of making a network request. To finish things off I'll briefly speak on what's new in swift generics and some limitations of those features.
Function Programming in Scala.
A lot of my examples here comes from the book
Functional programming in Scala By Paul Chiusano and Rúnar Bjarnason, It is a good book, buy it.
Asynchronous web apps with the Play Framework 2.0Oscar Renalias
Brief introduction to the asynchronous and reactive IO capabilities available in Play 2.0.
Source code of the demos available here: https://github.com/oscarrenalias/wjax-2012-play-async-apps
Greyhound - Powerful Pure Functional Kafka Library - Scala Love in the CityNatan Silnitsky
Wix has finally released to open-source its Kafka client SDK wrapper called Greyhound.
Completely re-written using the Scala functional library ZIO.
Greyhound harnesses ZIO's sophisticated async and concurrency features together with its easy composability to provide a superior experience to Kafka's own client SDKs.
It offers rich functionality including:
- Trivial setup of message processing parallelisation,
- Various fault tolerant retry policies (for consumers AND producers),
- Easy plug-ability of metrics publishing and context propagation and much more.
This talk will also show how Greyhound is used by Wix developers in more than 1500 event-driven microservices.
Not so long ago Microsoft announced a new language trageting on front-end developers. Everybody's reaction was like: Why?!! Is it just Microsoft darting back to Google?!
So, why a new language? JavaScript has its bad parts. Mostly you can avoid them or workaraund. You can emulate class-based OOP style, modules, scoping and even run-time typing. But that is doomed to be clumsy. That's not in the language design. Google has pointed out these flaws, provided a new language and failed. Will the story of TypeScript be any different?
Generic Functional Programming with Type ClassesTapio Rautonen
What it takes to build type assisted domain specific languages in Scala? Introducing the concepts of type classes, functional programming and generic algebra.
Think Async: Asynchronous Patterns in NodeJSAdam L Barrett
JavaScript is single threaded, so understanding the async patterns available in the language is critical to creating maintainable NodeJS applications with good performance. In order to master “thinking in async”, we’ll explore the async patterns available in node and JavaScript including standard callbacks, promises, thunks/tasks, the new async/await, the upcoming asynchronous iteration features, streams, CSP and ES Observables.
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
Terzaghi's soil bearing capacity theory, developed by Karl Terzaghi, is a fundamental principle in geotechnical engineering used to determine the bearing capacity of shallow foundations. This theory provides a method to calculate the ultimate bearing capacity of soil, which is the maximum load per unit area that the soil can support without undergoing shear failure. The Calculation HTML Code included.
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
Cosmetic shop management system project report.pdfKamal Acharya
Buying new cosmetic products is difficult. It can even be scary for those who have sensitive skin and are prone to skin trouble. The information needed to alleviate this problem is on the back of each product, but it's thought to interpret those ingredient lists unless you have a background in chemistry.
Instead of buying and hoping for the best, we can use data science to help us predict which products may be good fits for us. It includes various function programs to do the above mentioned tasks.
Data file handling has been effectively used in the program.
The automated cosmetic shop management system should deal with the automation of general workflow and administration process of the shop. The main processes of the system focus on customer's request where the system is able to search the most appropriate products and deliver it to the customers. It should help the employees to quickly identify the list of cosmetic product that have reached the minimum quantity and also keep a track of expired date for each cosmetic product. It should help the employees to find the rack number in which the product is placed.It is also Faster and more efficient way.
16. IO with Scala
● Confiner les effets de bords
val div: IO[Unit] = IO {
val a = io.StdIn.readInt()
val b = io.StdIn.readInt()
if (b == 0) throw new IllegalArgumentException()
else println(a / b)
}
div.runUnsafeSync //execute in real world
17. Real world app : Aerospike
● clé -> valeur
● In memory / SSD
● Clustering
18. IO with Aerospike
def put[A](key: Key, value: A)(client: AerospikeClient): IO[Unit] = IO.async { cb =>
val listener = new WriteListener {
override def onFailure(exception: AerospikeException): Unit = cb(Left(exception))
override def onSuccess(key: Key): Unit = cb(Right(()))
}
client.put(key, listener, bins)
}
val program: IO[Unit] = put(key, value)(client)
program.runUnsafeSync //execute in real world
19. IO with Aerospike
def put[A](key: Key, value: A)(client: AerospikeClient): IO[Unit] = IO.async { cb =>
val listener = new WriteListener {
override def onFailure(exception: AerospikeException): Unit = cb(Left(exception))
override def onSuccess(key: Key): Unit = cb(Right(()))
}
client.put(key, listener, bins)
}
val program: IO[Unit] = put(key, value)(client)
program.runUnsafeSync //execute in real world
20. IO with Aerospike
def put[A](key: Key, value: A)(client: AerospikeClient): IO[Unit] = IO.async { cb =>
val listener = new WriteListener {
override def onFailure(exception: AerospikeException): Unit = cb(Left(exception))
override def onSuccess(key: Key): Unit = cb(Right(()))
}
client.put(key, listener, bins)
}
val program: IO[Unit] = put(key, value)(client)
program.runUnsafeSync //execute in real world
21. AerospikeIO[T]
● Réduire le boilerplate
● Description de l’interaction
● Pas de code technique
● Monade IO spécifique
23. Algèbre (monadique)
sealed trait AerospikeIO[A]
case class Get[A](key: Key) extends AerospikeIO[A]
case class Put[A](key: Key, value: A) extends AerospikeIO[Unit]
case class Pure[A](x: A) extends AerospikeIO[A]
case class Join[A, B](x: AerospikeIO[A], y: AerospikeIO[B]) extends
AerospikeIO[(A, B)]
case class FlatMap[A, B](x: AerospikeIO[A], f: A => AerospikeIO[B]) extends
AerospikeIO[B]
24. Algèbre (monadique)
sealed trait AerospikeIO[A]
case class Get[A](key: Key) extends AerospikeIO[A]
case class Put[A](key: Key, value: A) extends AerospikeIO[Unit]
case class Pure[A](x: A) extends AerospikeIO[A]
case class Join[A, B](x: AerospikeIO[A], y: AerospikeIO[B]) extends
AerospikeIO[(A, B)]
case class FlatMap[A, B](x: AerospikeIO[A], f: A => AerospikeIO[B]) extends
AerospikeIO[B]
25. Algèbre (monadique)
sealed trait AerospikeIO[A]
case class Get[A](key: Key) extends AerospikeIO[A]
case class Put[A](key: Key, value: A) extends AerospikeIO[Unit]
case class Pure[A](x: A) extends AerospikeIO[A]
case class Join[A, B](x: AerospikeIO[A], y: AerospikeIO[B]) extends
AerospikeIO[(A, B)]
case class FlatMap[A, B](x: AerospikeIO[A], f: A => AerospikeIO[B]) extends
AerospikeIO[B]
26. Operations
case class Mark(name: String, value: Int)
val program: AerospikeIO[Mark] = for {
_ <- Put(keyBob, Mark("Bob", 17))
bobMark <- Get[Mark](keyBob)
} yield bobMark
28. Interpréteur : Transformation Naturelle
val nt = new (List ~> Option) {
def apply[A](list: List[A]): Option[A] = list match {
case Nil => None
case x :: xs => Some(x)
}
}
//nt(1 :: Nil) => Some(1)
29. Interpréteur : Kleisli
val keepPositiveValues = (i: Int) => if (i > 0) Some(i) else None
val lowerThanTen = (i: Int) => if (i < 10) Some(i) else None
keepPositiveValues.andThen(lowerThanTen)
30. Interpréteur : Kleisli
val keepPositiveValues = (i: Int) => if (i > 0) Some(i) else None
val lowerThanTen = (i: Int) => if (i < 10) Some(i) else None
keepPositiveValues.andThen(lowerThanTen) // doesn't compile!