functional

Functional programming in C Why The purpose of this library is to exercise an approach to functional programming in C on top of the existing standard vocabulary types such as and with the aim of eventually extending future revisions of the C standard library with the functionality found to work well How The library comes as two parts namespace is a faithful polyfill of the standard vocabulary types as specified for C 26 available to a C 20 compiler namespace extends them with the facilities useful in writing functional style programs and adds new vocabulary types Every type with a counterpart is a strict superset of it switching a valid program from types to changes neither compilation nor behaviour What The library provides the following utilities functors extensible system of encapsulation of monadic operations expressed with a pipe copack coproduct of types a sum of types similar to but indexed by type rather than order composes with the product of types choice monad monad built on top of the coproduct of types dispatch by overloading rules pack product of types similar to composes with the coproduct of types composition monadic computations combined side by side conjunction with disjunction with and their n ary folds and multidispatch dispatch any valid combination of product s and coproduct s to a function based on overloading rules graded monad integrate coproduct into and monads enables extensible error types and more Acknowledgments Gaper Aman for providing the inspiration in Fun ctional C and the M word Bartosz Milewski for taking the time to explain parametrised and graded monads and effect systems Ripple for allowing the main author the time to work on this library std expected std optional pfn pfn fn fn fn pfn pfn fn operator | std variant std tuple operator & operator | fn conjoin fn disjoin optional expected expected