Join the DZone community and get the full member experience.Join For Free
Jumpstart your Angular applications with Indigo.Design, a unified platform for visual design, UX prototyping, code generation, and app development.
Functional Reactive Programming (FRP) allows rich interaction in a functional setting. It answers the question, “How can I handle user input and update a GUI in a functional way?” FRP ends up making it much easier to create interactive GUIs and to work with complex sequences of synchronous and asynchronous events. Its ideas can be valuable in an imperative setting too.
FRP comes down to one simple idea: some values change over time. In FRP, these time-varying values are called signals and they update automatically.
FRP becomes truly powerful when paired with a good graphics library, making it possible to create interactive pages or design purely functional games.
Functional reactive programming (FRP) is a declarative approach to GUI design. The term declarative makes a distinction between the “what” and the “how” of programming. A declarative language allows you to say what is displayed, without having to specify exactly how the computer should do it.
The term declarative is important only because most current frameworks for graphical user interfaces are not declarative. They mire programmers in the many small, nonessential details of handling user input and manually modifying the display.
So with FRP, many of the irrelevant details are left to the compiler, freeing the programmer to think about things that matter. That means no event handlers, no callbacks, no DOM manipulations. These things simply are not necessary with FRP in Elm.
FRP makes tasks considerably easier by taking care of the messy “how” of events, display, and updates.
Demo:http:/ / elm-lang. org/ Examples. elm
Published at DZone with permission of Hirvesh Munogee , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.