SlideShare a Scribd company logo
A Theory of
Functional
Programming
Eric Normand
LambdUp December 6, 2017
A Theory of Functional Programming LambdUp
Newton’s Laws of
Motion
1. Inertia
2.
Acceleration
3.
Action-reaction
Force
Mass
Distance
Time
A Theory of Functional Programming LambdUp
Aristotelian
Physics
(excerpt)
Ideal speed
Natural place
Natural motion
Unnatural
motion
For the video and transcript
of this presentation,
click here:
https://lispcast.com/lambdup-2017-theory-functional-prog
ramming/
Why use Functional
Programming?
What is Functional
Programming?
paradigm
a philosophical and theoretical framework of a scientific
school or discipline within which theories, laws, and
generalizations and the experiments performed in
support of them are formulated
Merriam-Webster
philosophical or
theoretical framework,
world view
theories, laws,
generalizations
basic assumptions, ways
of thinking, methodology
Why use Functional
Programming?
What is Functional
Programming?
Goals of my Theory
• Explain what it is we (functional programmers) actually do
• in terms we can all understand
• Explain why it has advantages over other paradigms
• to people who haven’t done FP
• Avoid focusing on features
• Give explanatory and predictive power
• Self-described functional programmers should agree
My Theory of FP
Actions
Data
Calculations
Actions
the process of doing something, typically to achieve an aim
• Typically called Effects or Side-effects
• Depend on when you run them or how many times you run them
• Examples
• Sending a message over the network
• Writing to file system — other programs can see the change
• Changing or reading mutable state
Data
factual information used as a basis for reasoning, discussion, or calculation
• Inert
• Serializable
• Requiring interpretation
• Examples
• Numbers
• Bytes
• Strings
• Collections
Calculations
computation from inputs to outputs
• Mathematical functions
• Eternal — outside of time
• Referentially transparent
• Examples
• List concatenation
• Summing numbers
Contrast with OOP
OOP
Objects
References
Messages
Implementation
Haskell
• Data — built-in types and defined types
• Calculations — functions
• Actions — IO type
Implementation
Clojure
• Data — built-in types
• Calculations — pure functions
• Actions — impure functions
Further down the rabbit hole
• Everything “First-class”
• Data
• Calculations
• Actions
• Minimum necessary to program functionally in a language
Domains are separate
Data
Data + Data => Data
Examples
• Addition
• Concatenation
Calculations
Calc + Calc => Calc
Actions
• Contagious!
• Calculation + Action => Action
• Data + Action => Action
• Examples
• Print the square of a number — square => print!
• Parse the input as a number — read! => parse
Calculations
• Algebraic manipulation
• Turing complete
• implies the Halting problem
• Opaque
• What is this code going to do?
• Only way to know is to run it
Data
• Can represent something else
• Structure
• Known Big-O complexities
Refactorings
Actions
• Action => Action + Calculation
• Action => Action + Data
• Action => Action + Action
Calculations
• Calculation => Calculation + Data
• Calculation => Calculation + Calculation
Actions are universal
Actions
Calculations
Data
What counts as an Action?
Calculations
Timeless
Actions
Bound in time
Pure function Read/write to disk
Pure function
takes 24 hours to compute
Read/write to temp file as buffer
Actions
how many times they run
always matters - 0≠1≠more
launching a missile
sending an email
idempotent - 0≠1=more
setting public flag to true
free of side-effects - 0=1=more
GET request
reading mutable state
Actions
when they run
transactional read
guaranteed to be consistent
transactional+serialized writes
Order matters, but at least it’s some order
exactly once reads
Communicating Sequential Processes
Eric Normand
Follow Eric on:
Eric Normand @EricNormand
eric@lispcast.comlispcast.com

More Related Content

PDF
Kaggle Days Madrid - Alberto Danese
PDF
Training at AI Frontiers 2018 - Lukasz Kaiser: Sequence to Sequence Learning ...
PPTX
Craft of coding
PPTX
Different paradigms for problem solving.pptx
PPTX
Functional Programming.pptx
PPTX
algorithms and data structure Time complexity
PPTX
lecture1-2202211144eeeee24444444413.pptx
PPTX
lecture1-220221114413Algorithims and data structures.pptx
Kaggle Days Madrid - Alberto Danese
Training at AI Frontiers 2018 - Lukasz Kaiser: Sequence to Sequence Learning ...
Craft of coding
Different paradigms for problem solving.pptx
Functional Programming.pptx
algorithms and data structure Time complexity
lecture1-2202211144eeeee24444444413.pptx
lecture1-220221114413Algorithims and data structures.pptx

Similar to A Theory of Functional Programming LambdUp (20)

PPTX
tensorflow.pptx
PPTX
Functional Programming in C#
PPTX
RAJAT PROJECT.pptx
PPTX
Unit no_1.pptx
PPTX
Algorithms and Data Structures
PPTX
uw cse correct style and speed autumn 2020
PDF
Array computing and the evolution of SciPy, NumPy, and PyData
PPTX
Deep learning with tensorflow
PPT
Intro_2.ppt
PPT
Intro.ppt
PPT
Intro.ppt
ODP
Ardian Haxha- Flying with Python (OSCAL2014)
PDF
Good ideas that we forgot
PPTX
Data science and Hadoop
PPTX
Module 1_Artificial Intelligence_1234.pptx
PPTX
NYC Open Data Meetup-- Thoughtworks chief data scientist talk
PPTX
Data analysis using python in Jupyter notebook.pptx
PPT
Python programming
PPTX
Functional programming
PPT
Basic terminologies & asymptotic notations
tensorflow.pptx
Functional Programming in C#
RAJAT PROJECT.pptx
Unit no_1.pptx
Algorithms and Data Structures
uw cse correct style and speed autumn 2020
Array computing and the evolution of SciPy, NumPy, and PyData
Deep learning with tensorflow
Intro_2.ppt
Intro.ppt
Intro.ppt
Ardian Haxha- Flying with Python (OSCAL2014)
Good ideas that we forgot
Data science and Hadoop
Module 1_Artificial Intelligence_1234.pptx
NYC Open Data Meetup-- Thoughtworks chief data scientist talk
Data analysis using python in Jupyter notebook.pptx
Python programming
Functional programming
Basic terminologies & asymptotic notations
Ad

More from Eric Normand (9)

PDF
You are in a maze of deeply nested maps, all alike
PDF
The elements of a functional mindset
PDF
All I Needed for Functional Programming I Learned in High School Algebra
PDF
Lies My OO Teacher Told Me
PDF
What is Functional Programming?
PDF
Functional Programming for Business
PDF
Testing stateful, concurrent, and async systems using test.check
PDF
Building Composable Abstractions
PDF
ClojureScript: I can't believe this is JavaScript
You are in a maze of deeply nested maps, all alike
The elements of a functional mindset
All I Needed for Functional Programming I Learned in High School Algebra
Lies My OO Teacher Told Me
What is Functional Programming?
Functional Programming for Business
Testing stateful, concurrent, and async systems using test.check
Building Composable Abstractions
ClojureScript: I can't believe this is JavaScript
Ad

Recently uploaded (20)

PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Construction Project Organization Group 2.pptx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPT
Project quality management in manufacturing
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Welding lecture in detail for understanding
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Well-logging-methods_new................
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPT
Mechanical Engineering MATERIALS Selection
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Automation-in-Manufacturing-Chapter-Introduction.pdf
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Construction Project Organization Group 2.pptx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Project quality management in manufacturing
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Internet of Things (IOT) - A guide to understanding
CYBER-CRIMES AND SECURITY A guide to understanding
bas. eng. economics group 4 presentation 1.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Welding lecture in detail for understanding
Model Code of Practice - Construction Work - 21102022 .pdf
Well-logging-methods_new................
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Mechanical Engineering MATERIALS Selection
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...

A Theory of Functional Programming LambdUp