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

Chapter 11. Designing a Functional Application

Creating a whole application respecting the precepts of functional programming might seem like an impossible task. How can you write any meaningful software if you cannot have any side-effects? In order to perform any kind of computation, you will need at least some inputs and display results.

Functional languages have various mechanisms to circumvent those limitations. We will quickly present some of them so that you can have a better idea about how an application can be written in a purely functional way.

We will then learn more in depth about a paradigm called Functional Reactive Programming (FRP), as a way to design an application having a user interface. We will lay the foundation for using this technique in PHP to see if it is possible to use it to write a complete application.

In this chapter, you will learn about the following topics:

  • Writing a complete application in a purely functional language

  • Functional Reactive Programming

  • Designing a...