Functional PHP by Gilles Crettenand
Author:Gilles Crettenand [Crettenand, Gilles]
Language: eng
Format: epub, pdf
Tags: Computers, Programming Languages, Php, General, Web
ISBN: 9781785886911
Google: 21MoDwAAQBAJ
Amazon: B01MEEHEVK
Goodreads: 34383609
Publisher: Packt Publishing
Published: 2017-02-14T05:00:00+00:00
Writer monad
If you remember, pure functions cannot have any side effects, meaning you cannot put a debug statement in them, for example. If you are like me, the var_dump method is your debugging tool of choice, so you are left with breaking your purity rule or using some other debugging techniques. Since all outputs of a function must go through its return value, one of the first ideas that comes to mind is to return a tuple of values-the original return value and any kind of debug statement you need.
This solution is, however, pretty complex to put in place. Imagine you have a function that halves a numerical value which returns the halved value and the received input for debugging purposes. Now, if you want to compose this function by itself to create a new function that returns the value divided by four, you also need to modify the inputs so that they can accept your new return format. And this goes on and on until you've modified all your functions accordingly. This also poses some issues with currying, as you now have an extraneous parameter which is not really useful if you don't care about the debug statements.
The solution you are looking for is the Writer monad. Sadly, there are no implementations in php-functional library at the time of writing.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Management Strategies for the Cloud Revolution: How Cloud Computing Is Transforming Business and Why You Can't Afford to Be Left Behind by Charles Babcock(4131)
Ego Is the Enemy by Ryan Holiday(3991)
Offensive Shellcode from Scratch by Rishalin Pillay(3678)
Exploring Deepfakes by Bryan Lyon and Matt Tora(3270)
Robo-Advisor with Python by Aki Ranin(3052)
Learning C# by Developing Games with Unity 2021 by Harrison Ferrone(2875)
Speed Up Your Python with Rust by Maxwell Flitton(2852)
Liar's Poker by Michael Lewis(2812)
Agile Security Operations by Hinne Hettema(2807)
Linux Command Line and Shell Scripting Techniques by Vedran Dakic and Jasmin Redzepagic(2807)
OPNsense Beginner to Professional by Julio Cesar Bueno de Camargo(2806)
Extreme DAX by Michiel Rozema & Henk Vlootman(2790)
Essential Cryptography for JavaScript Developers by Alessandro Segala(2743)
Elevating React Web Development with Gatsby by Samuel Larsen-Disney(2733)
Python for ArcGIS Pro by Silas Toms Bill Parker(2648)
AI-Powered Commerce by Andy Pandharikar & Frederik Bussler(2642)
Incident Response Techniques for Ransomware Attacks by Oleg Skulkin(2628)
Distributed .NET with Microsoft Orleans by Bhupesh Guptha Muthiyalu Suneel Kumar Kunani(2628)
Cryptography Algorithms by Massimo Bertaccini(2627)