Applicative Programming, Disjoint Unions, Semigroups and Non-breaking Error Handling

Tony Morris

Abstract

This presentation is intended for the April 2010 meeting of the Brisbane Functional Programming Group

Programming with applicative functors [ApplicativeProg] generalises monadic programming permitting more available data types with fewer operations. However, these operations are sufficient for general handling of functions which may fail to compute a result and instead produce an error value. Further, these error values can be accumulated using an associative binary operation (semigroup).

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License Appendix C, Licence.

Questions and comments should be forwarded to Tony Morris Appendix B, Tony Morris - PGP Key.


Table of Contents

Introduction
This or That
What is a disjoint union?
Example
Validation
Example
Person
validAge
validName
validPostcode
What is an applicative functor?
Applicative Functor
Validation Applicative Functor
What is a semigroup?
Semigroup
Scala source
Let's put it all together
Validation.map
Validation.<<*>>
main
Let's Run It!
Conclusion
Bibliography
A. Validation.scala
B. Tony Morris - PGP Key
C. Licence

Introduction

What does it mean to use applicative programming, disjoint unions and semigroups for Non-breaking error handling?