oneof

std::initializer_list<t>.

There are plenty of reasons why functional APIs look and feel different than more common object-oriented APIs. A tell-tale sign of a functional APIs is existence ofand a set of methods withproperties. The abstraction part is of course about being able to talk about just the necessary details and nothing more. The algebraic part is about being able to take one or more instances of the same abstraction and being able to create a new one. I.e.,composing smaller parts into a bigger thing that is an instance of the same abstraction the original instances were.Composition by itself is nothing new to OO programmers. Composite, Decorator design patterns are all about putting together smaller pieces into something bigger. However, they miss out on the lawful part. Functional paradigm gives you extra guard rails so that you can bake in some well-understood mathematical properties into the abstraction.I think most people with even basic OO experience "get" the abstraction part. But the algebraic part, however, needs some thinking, some training, and most importantly some well-made, simple to understand examples.Speaking of examples, C++ has already adopted the ranges library as a technical specification (TS). At its core there are lawful algebraic properties. Understanding the functional principles from an industrial implementation is possible but harder. RxCpp is another example. Both libraries use operator overloading, which I think is a convenience and not a core part of the design. My focus today is understandability. So, here's my attempt to demystify the art ofwith a simple example of data generators. See cpp-generators ongithub.This talk presents two classic techniques from the functional domain — composable data generators and property-based testing — implemented in C++14 for testing a generic serialization and deserialization library (RefleX). It presents a systematic technique of constructing data generators from a mere random number generator and random type generation using compile-time meta-programming. The talk describes the laws of monoids, functors, applicative, and monads and how they are implemented in a simple to understand abstraction of data generators.Check out Slides . Transcripts below for a quick read.This is an attempt to demystify algebraic api design and buzz words like functor, monoid, and monads.I wish the book Functional Programming in C++ by Manning had a chapter on algebraic api design like the material covered in this talk.Property-based testing---the motivation behind data generators. Testing a serialization and deserialization library (Reflex)The RefleX library---Compile-time reflection in C++ for DDS-XTypesHow to test RefleX? What types and data should be used to test RefleX? We'll use property-based testing.A code and type generator machinery that hammers the code with unthinkable tests. It is developer's nightmare but also the best friend.Progression of the data generator abstraction...A simple random number generator---a built-in library functionA bool generator, an uppercase character generator---a custom function on top of the library function.A generator of random numbers within a range---a function with some state (a closure)generator from an