Book Image

Functional PHP

By : Gilles Crettenand
Book Image

Functional PHP

By: Gilles Crettenand

Overview of this book

<p>A functional approach encourages code reuse, greatly simplifies testing, and results in code that is concise and easy to understand. This book will demonstrate how PHP can also be used as a functional language, letting you learn about various function techniques to write maintainable and readable code.</p> <p>After a quick introduction to functional programming, we will dive right in with code examples so you can get the most of what you’ve just learned. We will go further with monads, memoization, and property-based testing. You will learn how to make use of modularity of function while writing functional PHP code.</p> <p>Through the tips and best practices in this book, you’ll be able to do more with less code and reduce bugs in your applications. Not only will you be able to boost your performance, but you will also find out how to eliminate common loop problems. By the end of the book, you will know a wide variety of new techniques that you can use on any new or legacy codebase.</p>
Table of Contents (19 chapters)
Functional PHP
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

From Functional Reactive Animation to Functional Reactive Programming


As is often the case when it comes to functional programming, the foundations behind the subject at hand date back a bit. In 1997, Conal Elliott and Paul Hudak published a paper called Functional Reactive Animation, or Fran.

The main goal of Fran is to allow the modeling of animations with two concepts called behaviors and events. Behaviors are values based on the current time, and events are conditions based on external or internal stimuli. Those two notions allow us to represent any kind of animation at any point in time although the animation itself is continuous.

Instead of directly creating the representation of your animation as it is usually the case, you describe it using behaviors and events. The interpretation, and thus representation, is then left to the underlying implementation. This is similar to what we just described. As events such as keyboard inputs or mouse clicks can be encoded inside Fran, the model...