SlideShare une entreprise Scribd logo
1  sur  27
Functional Reactive
Programming
指導老師:陳恭
學生:蔡詠捷
Introduce FRP
• FRP is a subset of Functional Programming
and Reactive Programming
What is FRP
• Use observer pattern.
• Modular way to code event-driven.
• Expressed as a reaction to its inputs.
• Expressed as a flow of data.
• Management of program state.
• Replaces the listeners and callbacks.
Why FRP?
• Compositionality.
• Declaratively programming style.
• Code structure like directed graph, and FRP
engine execution order automatically.
• FRP allows functional programming to be used
as a meta-language for writing event-based
logic
Why FRP?
• Interactive applications without the bugs
– Unpredictable order
– Missed first event
– Messy state
– Threading issues
– Leaking callbacks
– Accidental recursion
Life cycle of FRP
• Stage 1 : Initialization–Typically during
program start-up, FRP code statements are
converted into a directed graph in memory.
Life cycle of FRP
• Stage 2: Running–For the rest of the program
execution we feed values in, turn the crank
handle, and the FRP engine produces output.
Thinking in FRP
• Try to make things declaratively
• This style is referred to as declarative
programming
– We are telling the machine what the program is,
not what it does.
Sodium - FRP Library
• Sodium is a push-based system.
• Not all FRP systems use listeners internally.
• Push-based FRP systems typically do, but
there are also pull-based systems.
Fundamental data types
• Cell
– Represents a value that changes over time.
• Definition of Cell
– A container for a value that changes over time.
– Some FRP systems call it a behavior, property or a
signal
Fundamental data types
• Stream
– Represents a stream of events.
• Definition of Stream
– A stream of discrete events.
– It is also known in other FRP systems as event,
event stream, observable or signal.
– When an event propagates through a stream, we
sometimes say that the stream has fired.
Fundamental data types
• Arrows represent streams.
• Boxes represent transformations.
• Conceptual modules shown as clouds.
Lambda Syntax
• The new lambda syntax in Java 8 lets us write
this much shorter, with no fewer than six
variations of the syntax:
– (Integer k) -> { return k+1; }
– (k) -> { return k+1; }
– k -> { return k+1; }
– (Integer k) -> k+1
– (k) -> k+1
– k -> k+1
FRP Programming Tips
• Do not perform any I/O.
• Do not throw any exceptions unless they are
caught and handled within the function.
• Do not read the value of any external variable
if its value can change, but constants are
allowed and encourage.
• Do not modify any externally visible state.
FRP Programming Tips
• Do not keep any state between invocations of
the function.
• The function must have no external effects
other than through the returned value
• It must not be affected by any external state.
FRP primitives overview
Output as Stream Output as Cell Output as value
Stream map()
merge()/orElse()
snapshot()
filter()
never/new
Stream()
hold()
Cell switchS() map()
lift()
new Cell(constant)
switchC()
sample()
FRP Primitives
• map
– map transforms a Stream into a new Stream of
the same type or a different type.
FRP Primitives
• merge
– The merge primitives puts the events from two
streams together into a single stream.
FRP Primitives
• hold
– The hold primitive converts a stream into a cell in
such a way that the cell's value is that of the most
recent event received.
– Also named stepper or toProperty.
FRP Primitives
• snapshot
– The snapshot primitive captures the value of a cell
at the time when a stream event fires, and it can
then combine the stream and cell events together
with a supplied function.
– Also named withLatest, attach, or tag.
FRP Primitives
• filter
– To filter a stream is to let values through only
sometimes.
FRP Primitives
• lift
– Lift is a functional programming term meaning
(more generally) to make a function that operates
on values into a function that operates on some
type of container of those values.
FRP Primitives
• never
– In FRP a never stream is one that can't ever fire.
This name is universal in FRP systems.
– Only use in Stream.
FRP Primitives
• constant
– Cells usually change over time, but it's also
possible to construct them with a constant value.
– There is no way to modify a cell after it is created,
so its value is guaranteed to be constant forever.
– Only use in Cell.
FRP Primitives
• sample
– Return the value of the cell.
Link
• Example of the book :
– https://github.com/SodiumFRP
• Example of my own view :
– https://github.com/PhyrexTsai/SodiumFRPExample/
Reference
• S. Blackheath, A. Jones. Functional Reactive
Programming

Contenu connexe

Tendances

Welch Verolog 2013
Welch Verolog 2013Welch Verolog 2013
Welch Verolog 2013
Philip Welch
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
Manoj Patil
 
Lecture2 1 types of programming languages
Lecture2 1 types of programming languagesLecture2 1 types of programming languages
Lecture2 1 types of programming languages
Yog Maya
 
Владимир Иванов. JIT для Java разработчиков
Владимир Иванов. JIT для Java разработчиковВладимир Иванов. JIT для Java разработчиков
Владимир Иванов. JIT для Java разработчиков
Volha Banadyseva
 
Task Parallel Library Data Flows
Task Parallel Library Data FlowsTask Parallel Library Data Flows
Task Parallel Library Data Flows
SANKARSAN BOSE
 

Tendances (20)

Introduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsIntroduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actors
 
Hm system programming class 1
Hm system programming class 1Hm system programming class 1
Hm system programming class 1
 
Introduction of A Lightweight Stage-Programming Framework
Introduction of A Lightweight Stage-Programming FrameworkIntroduction of A Lightweight Stage-Programming Framework
Introduction of A Lightweight Stage-Programming Framework
 
Welch Verolog 2013
Welch Verolog 2013Welch Verolog 2013
Welch Verolog 2013
 
Lecture6
Lecture6Lecture6
Lecture6
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
 
Concept Drift: Monitoring Model Quality In Streaming ML Applications
Concept Drift: Monitoring Model Quality In Streaming ML ApplicationsConcept Drift: Monitoring Model Quality In Streaming ML Applications
Concept Drift: Monitoring Model Quality In Streaming ML Applications
 
Unit 3
Unit 3Unit 3
Unit 3
 
Lecture2 1 types of programming languages
Lecture2 1 types of programming languagesLecture2 1 types of programming languages
Lecture2 1 types of programming languages
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 
Streaming your Lyft Ride Prices - Flink Forward SF 2019
Streaming your Lyft Ride Prices - Flink Forward SF 2019Streaming your Lyft Ride Prices - Flink Forward SF 2019
Streaming your Lyft Ride Prices - Flink Forward SF 2019
 
Ml also helps generic compiler ?
Ml also helps generic compiler ?Ml also helps generic compiler ?
Ml also helps generic compiler ?
 
Владимир Иванов. JIT для Java разработчиков
Владимир Иванов. JIT для Java разработчиковВладимир Иванов. JIT для Java разработчиков
Владимир Иванов. JIT для Java разработчиков
 
Task Parallel Library Data Flows
Task Parallel Library Data FlowsTask Parallel Library Data Flows
Task Parallel Library Data Flows
 
Callgraph analysis
Callgraph analysisCallgraph analysis
Callgraph analysis
 
Ch 4 linker loader
Ch 4 linker loaderCh 4 linker loader
Ch 4 linker loader
 
Functional Programming in Java
Functional Programming in JavaFunctional Programming in Java
Functional Programming in Java
 
Service-Oriented Architectures: From Design to Production Exploiting Workflow...
Service-Oriented Architectures: From Design to Production Exploiting Workflow...Service-Oriented Architectures: From Design to Production Exploiting Workflow...
Service-Oriented Architectures: From Design to Production Exploiting Workflow...
 
Lecture1 introduction compilers
Lecture1 introduction compilersLecture1 introduction compilers
Lecture1 introduction compilers
 
Julia Computing - an alternative to Hadoop
Julia Computing - an alternative to HadoopJulia Computing - an alternative to Hadoop
Julia Computing - an alternative to Hadoop
 

En vedette

1.7 functional programming
1.7 functional programming1.7 functional programming
1.7 functional programming
futurespective
 
16 logical programming
16 logical programming16 logical programming
16 logical programming
jigeno
 

En vedette (20)

The essence of Reactive Programming
The essence of Reactive ProgrammingThe essence of Reactive Programming
The essence of Reactive Programming
 
1.7 functional programming
1.7 functional programming1.7 functional programming
1.7 functional programming
 
Elm & Elixir: Functional Programming and Web
Elm & Elixir: Functional Programming and WebElm & Elixir: Functional Programming and Web
Elm & Elixir: Functional Programming and Web
 
The taste of F#
The taste of F#The taste of F#
The taste of F#
 
Designing with Capabilities
Designing with CapabilitiesDesigning with Capabilities
Designing with Capabilities
 
Real-World Functional Programming @ Incubaid
Real-World Functional Programming @ IncubaidReal-World Functional Programming @ Incubaid
Real-World Functional Programming @ Incubaid
 
Doge-driven design
Doge-driven designDoge-driven design
Doge-driven design
 
The Theory of Chains
The Theory of ChainsThe Theory of Chains
The Theory of Chains
 
Slick 3.0 functional programming and db side effects
Slick 3.0   functional programming and db side effectsSlick 3.0   functional programming and db side effects
Slick 3.0 functional programming and db side effects
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Dr Frankenfunctor and the Monadster
Dr Frankenfunctor and the MonadsterDr Frankenfunctor and the Monadster
Dr Frankenfunctor and the Monadster
 
Swift vs. Language X
Swift vs. Language XSwift vs. Language X
Swift vs. Language X
 
Functional Programming with C#
Functional Programming with C#Functional Programming with C#
Functional Programming with C#
 
16 logical programming
16 logical programming16 logical programming
16 logical programming
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013
 
Designing with capabilities (DDD-EU 2017)
Designing with capabilities (DDD-EU 2017)Designing with capabilities (DDD-EU 2017)
Designing with capabilities (DDD-EU 2017)
 
Thirteen ways of looking at a turtle
Thirteen ways of looking at a turtleThirteen ways of looking at a turtle
Thirteen ways of looking at a turtle
 
Functional Programming in C# and F#
Functional Programming in C# and F#Functional Programming in C# and F#
Functional Programming in C# and F#
 
[FT-11][ltchen] A Tale of Two Monads
[FT-11][ltchen] A Tale of Two Monads[FT-11][ltchen] A Tale of Two Monads
[FT-11][ltchen] A Tale of Two Monads
 

Similaire à Frp

Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming language
Vasavi College of Engg
 
Reactive programming using rx java & akka actors - pdx-scala - june 2014
Reactive programming   using rx java & akka actors - pdx-scala - june 2014Reactive programming   using rx java & akka actors - pdx-scala - june 2014
Reactive programming using rx java & akka actors - pdx-scala - june 2014
Thomas Lockney
 
JAVA 8 Parallel Stream
JAVA 8 Parallel StreamJAVA 8 Parallel Stream
JAVA 8 Parallel Stream
Tengwen Wang
 
Reactive Streams, linking Reactive Application to Spark Streaming by Luc Bour...
Reactive Streams, linking Reactive Application to Spark Streaming by Luc Bour...Reactive Streams, linking Reactive Application to Spark Streaming by Luc Bour...
Reactive Streams, linking Reactive Application to Spark Streaming by Luc Bour...
Spark Summit
 

Similaire à Frp (20)

10 implementing subprograms
10 implementing subprograms10 implementing subprograms
10 implementing subprograms
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming language
 
Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)
 
Lambda.pdf
Lambda.pdfLambda.pdf
Lambda.pdf
 
Lecture7
Lecture7Lecture7
Lecture7
 
Presentation systemc
Presentation systemcPresentation systemc
Presentation systemc
 
Lagom - Mircoservices "Just Right"
Lagom - Mircoservices "Just Right"Lagom - Mircoservices "Just Right"
Lagom - Mircoservices "Just Right"
 
Monolithic and Procedural Programming
Monolithic and Procedural ProgrammingMonolithic and Procedural Programming
Monolithic and Procedural Programming
 
Polyglot and functional (Devoxx Nov/2011)
Polyglot and functional (Devoxx Nov/2011)Polyglot and functional (Devoxx Nov/2011)
Polyglot and functional (Devoxx Nov/2011)
 
Spark Summit EU talk by Mikhail Semeniuk Hollin Wilkins
Spark Summit EU talk by Mikhail Semeniuk Hollin WilkinsSpark Summit EU talk by Mikhail Semeniuk Hollin Wilkins
Spark Summit EU talk by Mikhail Semeniuk Hollin Wilkins
 
Reactive programming using rx java & akka actors - pdx-scala - june 2014
Reactive programming   using rx java & akka actors - pdx-scala - june 2014Reactive programming   using rx java & akka actors - pdx-scala - june 2014
Reactive programming using rx java & akka actors - pdx-scala - june 2014
 
Scalable Data Science with SparkR: Spark Summit East talk by Felix Cheung
Scalable Data Science with SparkR: Spark Summit East talk by Felix CheungScalable Data Science with SparkR: Spark Summit East talk by Felix Cheung
Scalable Data Science with SparkR: Spark Summit East talk by Felix Cheung
 
Reactive Streams, Linking Reactive Application To Spark Streaming
Reactive Streams, Linking Reactive Application To Spark StreamingReactive Streams, Linking Reactive Application To Spark Streaming
Reactive Streams, Linking Reactive Application To Spark Streaming
 
JAVA 8 Parallel Stream
JAVA 8 Parallel StreamJAVA 8 Parallel Stream
JAVA 8 Parallel Stream
 
Get Functional Programming with Clojure
Get Functional Programming with ClojureGet Functional Programming with Clojure
Get Functional Programming with Clojure
 
Reactive Streams, linking Reactive Application to Spark Streaming by Luc Bour...
Reactive Streams, linking Reactive Application to Spark Streaming by Luc Bour...Reactive Streams, linking Reactive Application to Spark Streaming by Luc Bour...
Reactive Streams, linking Reactive Application to Spark Streaming by Luc Bour...
 
Survey of Program Transformation Technologies
Survey of Program Transformation TechnologiesSurvey of Program Transformation Technologies
Survey of Program Transformation Technologies
 
Reactive Software Systems
Reactive Software SystemsReactive Software Systems
Reactive Software Systems
 
Thinking Functionally - John Stevenson - Codemotion Rome 2017
Thinking Functionally - John Stevenson - Codemotion Rome 2017Thinking Functionally - John Stevenson - Codemotion Rome 2017
Thinking Functionally - John Stevenson - Codemotion Rome 2017
 
Thinking Functionally with Clojure
Thinking Functionally with ClojureThinking Functionally with Clojure
Thinking Functionally with Clojure
 

Dernier

Digital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptxDigital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptx
MohamedFarag457087
 
POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.
Cherry
 
Human genetics..........................pptx
Human genetics..........................pptxHuman genetics..........................pptx
Human genetics..........................pptx
Cherry
 

Dernier (20)

Digital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptxDigital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptx
 
Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....
Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....
Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....
 
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...
 
Genetics and epigenetics of ADHD and comorbid conditions
Genetics and epigenetics of ADHD and comorbid conditionsGenetics and epigenetics of ADHD and comorbid conditions
Genetics and epigenetics of ADHD and comorbid conditions
 
POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.
 
Role of AI in seed science Predictive modelling and Beyond.pptx
Role of AI in seed science  Predictive modelling and  Beyond.pptxRole of AI in seed science  Predictive modelling and  Beyond.pptx
Role of AI in seed science Predictive modelling and Beyond.pptx
 
Dr. E. Muralinath_ Blood indices_clinical aspects
Dr. E. Muralinath_ Blood indices_clinical  aspectsDr. E. Muralinath_ Blood indices_clinical  aspects
Dr. E. Muralinath_ Blood indices_clinical aspects
 
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRingsTransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
 
Early Development of Mammals (Mouse and Human).pdf
Early Development of Mammals (Mouse and Human).pdfEarly Development of Mammals (Mouse and Human).pdf
Early Development of Mammals (Mouse and Human).pdf
 
FAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical ScienceFAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical Science
 
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryFAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
 
Call Girls Ahmedabad +917728919243 call me Independent Escort Service
Call Girls Ahmedabad +917728919243 call me Independent Escort ServiceCall Girls Ahmedabad +917728919243 call me Independent Escort Service
Call Girls Ahmedabad +917728919243 call me Independent Escort Service
 
module for grade 9 for distance learning
module for grade 9 for distance learningmodule for grade 9 for distance learning
module for grade 9 for distance learning
 
GBSN - Microbiology (Unit 3)Defense Mechanism of the body
GBSN - Microbiology (Unit 3)Defense Mechanism of the body GBSN - Microbiology (Unit 3)Defense Mechanism of the body
GBSN - Microbiology (Unit 3)Defense Mechanism of the body
 
Human genetics..........................pptx
Human genetics..........................pptxHuman genetics..........................pptx
Human genetics..........................pptx
 
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIACURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
 
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICEPATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
 
Plasmid: types, structure and functions.
Plasmid: types, structure and functions.Plasmid: types, structure and functions.
Plasmid: types, structure and functions.
 
Terpineol and it's characterization pptx
Terpineol and it's characterization pptxTerpineol and it's characterization pptx
Terpineol and it's characterization pptx
 
Cyanide resistant respiration pathway.pptx
Cyanide resistant respiration pathway.pptxCyanide resistant respiration pathway.pptx
Cyanide resistant respiration pathway.pptx
 

Frp

  • 2. Introduce FRP • FRP is a subset of Functional Programming and Reactive Programming
  • 3. What is FRP • Use observer pattern. • Modular way to code event-driven. • Expressed as a reaction to its inputs. • Expressed as a flow of data. • Management of program state. • Replaces the listeners and callbacks.
  • 4. Why FRP? • Compositionality. • Declaratively programming style. • Code structure like directed graph, and FRP engine execution order automatically. • FRP allows functional programming to be used as a meta-language for writing event-based logic
  • 5. Why FRP? • Interactive applications without the bugs – Unpredictable order – Missed first event – Messy state – Threading issues – Leaking callbacks – Accidental recursion
  • 6. Life cycle of FRP • Stage 1 : Initialization–Typically during program start-up, FRP code statements are converted into a directed graph in memory.
  • 7. Life cycle of FRP • Stage 2: Running–For the rest of the program execution we feed values in, turn the crank handle, and the FRP engine produces output.
  • 8. Thinking in FRP • Try to make things declaratively • This style is referred to as declarative programming – We are telling the machine what the program is, not what it does.
  • 9. Sodium - FRP Library • Sodium is a push-based system. • Not all FRP systems use listeners internally. • Push-based FRP systems typically do, but there are also pull-based systems.
  • 10. Fundamental data types • Cell – Represents a value that changes over time. • Definition of Cell – A container for a value that changes over time. – Some FRP systems call it a behavior, property or a signal
  • 11. Fundamental data types • Stream – Represents a stream of events. • Definition of Stream – A stream of discrete events. – It is also known in other FRP systems as event, event stream, observable or signal. – When an event propagates through a stream, we sometimes say that the stream has fired.
  • 12. Fundamental data types • Arrows represent streams. • Boxes represent transformations. • Conceptual modules shown as clouds.
  • 13. Lambda Syntax • The new lambda syntax in Java 8 lets us write this much shorter, with no fewer than six variations of the syntax: – (Integer k) -> { return k+1; } – (k) -> { return k+1; } – k -> { return k+1; } – (Integer k) -> k+1 – (k) -> k+1 – k -> k+1
  • 14. FRP Programming Tips • Do not perform any I/O. • Do not throw any exceptions unless they are caught and handled within the function. • Do not read the value of any external variable if its value can change, but constants are allowed and encourage. • Do not modify any externally visible state.
  • 15. FRP Programming Tips • Do not keep any state between invocations of the function. • The function must have no external effects other than through the returned value • It must not be affected by any external state.
  • 16. FRP primitives overview Output as Stream Output as Cell Output as value Stream map() merge()/orElse() snapshot() filter() never/new Stream() hold() Cell switchS() map() lift() new Cell(constant) switchC() sample()
  • 17. FRP Primitives • map – map transforms a Stream into a new Stream of the same type or a different type.
  • 18. FRP Primitives • merge – The merge primitives puts the events from two streams together into a single stream.
  • 19. FRP Primitives • hold – The hold primitive converts a stream into a cell in such a way that the cell's value is that of the most recent event received. – Also named stepper or toProperty.
  • 20. FRP Primitives • snapshot – The snapshot primitive captures the value of a cell at the time when a stream event fires, and it can then combine the stream and cell events together with a supplied function. – Also named withLatest, attach, or tag.
  • 21. FRP Primitives • filter – To filter a stream is to let values through only sometimes.
  • 22. FRP Primitives • lift – Lift is a functional programming term meaning (more generally) to make a function that operates on values into a function that operates on some type of container of those values.
  • 23. FRP Primitives • never – In FRP a never stream is one that can't ever fire. This name is universal in FRP systems. – Only use in Stream.
  • 24. FRP Primitives • constant – Cells usually change over time, but it's also possible to construct them with a constant value. – There is no way to modify a cell after it is created, so its value is guaranteed to be constant forever. – Only use in Cell.
  • 25. FRP Primitives • sample – Return the value of the cell.
  • 26. Link • Example of the book : – https://github.com/SodiumFRP • Example of my own view : – https://github.com/PhyrexTsai/SodiumFRPExample/
  • 27. Reference • S. Blackheath, A. Jones. Functional Reactive Programming

Notes de l'éditeur

  1. 使用觀察者模式 用模組化方式撰寫事件驅動程式 表示輸入的反應 表示資料的流程 程序狀態管理 取代傳統的 listeners 與 callbacks
  2. 程式可組合性 聲明式的程式撰寫方式 程式結構類似圖形,並且FRP的引擎會自動執行 FRP 可以使用 functional programming 來寫 event-base 的邏輯
  3. 順序不可預期性 Miss 第一個 event 麻煩的 state
  4. Initialize 的時候會將 FRP code 都轉成圖形化存在記憶體內
  5. 在執行階段的時候會將輸入的值透過FRP引擎轉成輸出值
  6. 聲明式的表達一件事情
  7. Sodium 使用 Push-based
  8. Discrete 分離