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
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
370
SwfControl
ron
0
70
Other Decks in Programming
See All in Programming
リアルな遅延を測る仕様
kota_yata
1
130
Loosening the Reins: Go Generics Get More Flexible
kuro_kurorrr
0
360
Flow は今どうなっているか
mizdra
PRO
0
840
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
760
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
130
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
220
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
130
源内ハンズオン概要編
hideg
0
240
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
140
プロポーザルを書いてもらう
pvcresin
0
600
自分的「カンファレンスの楽しみ方」
syumai
0
170
Featured
See All Featured
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.7k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
300
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
400
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
840
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
230
Designing Experiences People Love
moore
143
24k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Fireside Chat
paigeccino
42
4k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
970
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
640
Utilizing Notion as your number one productivity tool
mfonobong
4
560
ラッコキーワード サービス紹介資料
rakko
1
4.7M
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