Showing posts with label cpp_fp. Show all posts
Showing posts with label cpp_fp. Show all posts

Nov 6, 2025

[software design][functional programming] Referential transparency

Referential transparency

An expression is referentially transparent if it can be replaced with its corresponding value without changing the program's behavior.

This means that for a function to be referentially transparent, it must be a pure function, which has two key properties:

  • It always returns the same output for the same inputs.
  • It has no side effects. (It doesn't modify global variables, print to the console, read from a file, make a network request, etc.)


Mar 30, 2019

[C++17] compile time checking type is an instance of a type template

Book Functional Programming in C++ (by Ivan Čukić) by far is the best functional programming book for C++

Other informative document are:
https://github.com/fons/functional-cpp/tree/master/docs

Ivan had a post about how to use variadic template argument to detect a type is an instance of type template.

Reference:
https://cukic.co/2019/03/15/template-meta-functions-for-detecting-template-instantiation/

code in action:

Aug 26, 2016

[FP] Related read/study links

Reading/learning process:
  1. C++ template, the definitive guide
  2. Modern C++ design
  3. -- Above 2 books are essential for me to understand the type system in programming language in general. --
  4. Functors, Applicatives, And Monads In Pictures
  5. Yet Another Monad Tutorial (part 2: >>= and return)
  6. Monads in C++
  7. functional-cpp
  8. PyMonad
  9. Functional Programming Patterns (NDC London 2014)
  10. Railway Oriented Programming


Used boost::mpl in SRM code base intensively; as for daily coding,
having pure function, function composition in mind as the basic design of the programs.


Resources:
Category Theory:
Category Theory for the Sciences


Monad:
--
Yet Another Monad Tutorial (part 2: >>= and return)
--
Functors, Applicatives, And Monads In Pictures
Monads Demystified
Using Monads in C++ to Solve Constraints: 1. The List Monad
Monads in C++
Haskell/Understanding monads
Monad 最简介绍
函数式编程
單子 (monad) 入門(一)
單子 (monad) 入門(二)讀取單子
Understanding_monads


Condition & restarts:
Conditions and Restarts
What's a condition system and why do you want one?
Google group discussion: A tale of restarts


FP slides:
Functional Programming Patterns (NDC London 2014)
Railway Oriented Programming


Jargon of FP:
functional-programming-jargon


Haskell:
Learn You a Haskell for Great Good!
A Fistful of Monads


FP in C++ Document:
functional-cpp


C++ FP Library:
Hana Library: Monad
https://cat.github.io/
FTL - The Functional Template Library
FC++: Functional Programming in C++


Python Library:
PyMonad


javascript:
Monads in JavaScript (7 min read)


Reddit talk:
reddit