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
350
SwfControl
ron
0
59
Other Decks in Programming
See All in Programming
Java 21/25 Virtual Threads 소개
debop
0
340
一度始めたらやめられない開発効率向上術 / Findy あなたのdotfilesを教えて!
k0kubun
4
2.9k
Radical Imagining - LIFT 2025-2027 Policy Agenda
lift1998
0
250
仕様漏れ実装漏れをなくすトレーサビリティAI基盤のご紹介
orgachem
PRO
9
5.4k
AIエージェントで業務改善してみた
taku271
0
500
瑠璃の宝石に学ぶ技術の声の聴き方 / 【劇場版】アニメから得た学びを発表会2026 #エンジニアニメ
mazrean
0
230
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
150
10 Tips of AWS ~Gen AI on AWS~
licux
5
250
実践CRDT
tamadeveloper
0
430
ネイティブアプリとWebフロントエンドのAPI通信ラッパーにおける共通化の勘所
suguruooki
0
260
ファインチューニングせずメインコンペを解く方法
pokutuna
0
300
PHPで TLSのプロトコルを実装してみる
higaki_program
0
750
Featured
See All Featured
sira's awesome portfolio website redesign presentation
elsirapls
0
210
AI: The stuff that nobody shows you
jnunemaker
PRO
5
540
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
500
The Invisible Side of Design
smashingmag
302
51k
A better future with KSS
kneath
240
18k
The SEO identity crisis: Don't let AI make you average
varn
0
440
Producing Creativity
orderedlist
PRO
348
40k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.4k
The browser strikes back
jonoalderson
0
940
Git: the NoSQL Database
bkeepers
PRO
432
67k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.4k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
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