Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Functional Programming Patterns
Search
Robin Palotai
September 18, 2012
Programming
490
7
Share
Functional Programming Patterns
A short enumeration of selected patters occuring in FP.
Robin Palotai
September 18, 2012
More Decks by Robin Palotai
See All by Robin Palotai
A subjective on Functional Programming
ron
4
360
SwfControl
ron
0
65
Other Decks in Programming
See All in Programming
ビジネスモデルから紐解く、AI+型駆動開発
hirokiomote
2
4.8k
SPMマルチモジュールで テストカバレッジを取得する技法
yosshi4486
0
130
CSC307 Lecture 17
javiergs
PRO
0
300
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
270
Inspired By RubyKaigi (EN)
atzzcokek
0
460
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
210
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
300
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
330
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
430
権限チェックの一貫性を型で守る TypeScript による多層防御
mnch
4
990
関係性から理解する"同一性"の型用語たち
pvcresin
2
620
Swiftのレキシカルスコープ管理
kntkymt
0
210
Featured
See All Featured
A Tale of Four Properties
chriscoyier
163
24k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
720
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
200
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
180
4 Signs Your Business is Dying
shpigford
187
22k
Building an army of robots
kneath
306
46k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
540
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
520
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
430
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
How GitHub (no longer) Works
holman
316
150k
How to Talk to Developers About Accessibility
jct
2
210
Transcript
Functional Programming Patterns
1st class functions Functions are values too. They have type.
Can be assigned to variables. f: a b → g: (a, b) c → input type output type → multiple arguments
Higher order funs A higher order function is a function
that takes other functions as argument. h: ([a], a b) [b] → → list elem mapper Strategy pattern-like
Currying f: (a, b) c → f: a b c
→ → f: a (b c) → → curried form right-associative Factory pattern-like
Pure Functions Referential transparency – expression replaceable with its value
without changing program semantics. easy to reason about optimizable
Immutability Values are constructed and then never modified. persistent collections
tuples and Lists pair: (a, b) 3-tuple: (a, b, c)
1 :: 2 :: 3 :: Nil [1, [2, [3, []]]] heterogeneous fixed lengthc homogeneous unbounded length
Transform Recursion is low-level flow control. Usages can be abstracted.
Tell what, not how. map, filter, fold
Algebraic Data Types data List a = Cons a (List
a) | Nil data Tree a = Node (Tree a) a (Tree a) | Empty
Functor A functor is a computational context. Map applies a
normal function to a value in a context. map: f a (a b) f b → → → F<A> (A B) F<B> → → → fmap
Monad point: a f a → flatMap: f a (a
f b) f → → → b A context with richer operations. pure, return bind
Option Nulls made explicit. No more NPE. data Option a
= Some a | None orElse: Opt a Opt a Opt a → → getOrElse: Opt a a a → → Monad
Either data Either a b = Left a | Right
b Often used for error handling, where error is on the left, success on the right. Monad for a fixed a
Future Promise / Future is a context, where the contained
computation may execute concurrently. Used to compose async computations without blocking. Monad
Typeclasses A typeclass describes a contract. A typeclass instance describes
how a given data type fulfills that contract. Like an Adapter, but more versatile.
Semigroup Monoid , Semigroup defines addition. Monoid is semigroup with
an identity element. Pops all over your code!
Foldable A foldable provides means for stateful traversal. foldLeft: f
a b (b a b) b → → → → → Nice cooperation with Monoids
Extra stuff Applicative functors, Monad transformers, Relational databases, Linear logic,
IO, DI, Logging, Total FP, Actors, ...
Thx