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
今からFlash開発できるわけないじゃん、ムリムリ! (※ムリじゃなかった!?)
arkw
0
180
Going Multiplatform with Your Android App (Android Makers 2026)
zsmb
2
340
AIと共にエンジニアとPMの “二刀流”を実現する
naruogram
0
130
Radical Imagining - LIFT 2025-2027 Policy Agenda
lift1998
0
250
ネイティブアプリとWebフロントエンドのAPI通信ラッパーにおける共通化の勘所
suguruooki
0
250
forteeの改修から振り返るPHPerKaigi 2026
muno92
PRO
3
240
今年もTECHSCOREブログを書き続けます!
hiraoku101
0
220
GoのDB アクセスにおける 「型安全」と「柔軟性」の両立 - Bob という選択肢
tak848
0
310
10年分の技術的負債、完済へ ― Claude Code主導のAI駆動開発でスポーツブルを丸ごとリプレイスした話
takuya_houshima
0
1.7k
2026-03-27 #terminalnight 変数展開とコマンド展開でターミナル作業をスマートにする方法
masasuzu
0
300
Go_College_最終発表資料__外部公開用_.pdf
xe_pc23
0
130
飯MCP
yusukebe
0
480
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Test your architecture with Archunit
thirion
1
2.2k
Paper Plane
katiecoart
PRO
1
49k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
360
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
New Earth Scene 8
popppiees
2
2k
Typedesign – Prime Four
hannesfritz
42
3k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
260
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
280
Bash Introduction
62gerente
615
210k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
10k
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