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
7
480
Functional Programming Patterns
A short enumeration of selected patters occuring in FP.
Robin Palotai
September 18, 2012
Tweet
Share
More Decks by Robin Palotai
See All by Robin Palotai
A subjective on Functional Programming
ron
4
340
SwfControl
ron
0
33
Other Decks in Programming
See All in Programming
Amazon Nova Reelの可能性
hideg
0
260
AWS Lambda functions with C# 用の Dev Container Template を作ってみた件
mappie_kochi
0
220
JavaScriptツール群「UnJS」を5分で一気に駆け巡る!
k1tikurisu
8
1.3k
Terraform で作る Amazon ECS の CI/CD パイプライン
hiyanger
0
110
Azure AI Foundryのご紹介
qt_luigi
1
260
BEエンジニアがFEの業務をできるようになるまでにやったこと
yoshida_ryushin
0
260
Внедряем бюджетирование, или Как сделать хорошо?
lamodatech
0
980
はてなにおけるfujiwara-wareの活用やecspressoのCI/CD構成 / Fujiwara Tech Conference 2025
cohalz
3
3.2k
令和7年版 あなたが使ってよいフロントエンド機能とは
mugi_uno
12
6.1k
Оптимизируем производительность блока Казначейство
lamodatech
0
990
盆栽転じて家具となる / Bonsai and Furnitures
aereal
0
2.2k
Pythonでもちょっとリッチな見た目のアプリを設計してみる
ueponx
0
230
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
113
50k
How to Ace a Technical Interview
jacobian
276
23k
Why Our Code Smells
bkeepers
PRO
335
57k
GraphQLとの向き合い方2022年版
quramy
44
13k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Designing for Performance
lara
604
68k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
192
16k
How GitHub (no longer) Works
holman
312
140k
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