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
Parallel Universes - Reader and Coreader for Sw...
Search
Elmar Kretzer
September 30, 2017
Programming
1
210
Parallel Universes - Reader and Coreader for Swift DI
Slides are from my talk at Functional Swift Conference 2017 in Berlin.
http://www.funswiftconf.com
Elmar Kretzer
September 30, 2017
Tweet
Share
More Decks by Elmar Kretzer
See All by Elmar Kretzer
Reusable Animations in Swift
elmkretzer
2
400
A swift 4 KeyPath journey
elmkretzer
2
980
Palau - NSUserDefaults with Wings!
elmkretzer
1
170
Swift Generics
elmkretzer
4
410
Migrating Objective-C to Swift
elmkretzer
0
200
Other Decks in Programming
See All in Programming
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
150
Go Modules: From Basics to Beyond / Go Modulesの基本とその先へ
kuro_kurorrr
0
120
XP, Testing and ninja testing
m_seki
2
140
git worktree × Claude Code × MCP ~生成AI時代の並列開発フロー~
hisuzuya
0
230
Kotlin エンジニアへ送る:Swift 案件に参加させられる日に備えて~似てるけど色々違う Swift の仕様 / from Kotlin to Swift
lovee
1
250
Webからモバイルへ Vue.js × Capacitor 活用事例
naokihaba
0
740
DroidKnights 2025 - 다양한 스크롤 뷰에서의 영상 재생
gaeun5744
3
300
Create a website using Spatial Web
akkeylab
0
290
KotlinConf 2025 現地で感じたServer-Side Kotlin
n_takehata
1
220
イベントストーミング図からコードへの変換手順 / Procedure for Converting Event Storming Diagrams to Code
nrslib
1
190
Java on Azure で LangGraph!
kohei3110
0
160
iOSアプリ開発で 関数型プログラミングを実現する The Composable Architectureの紹介
yimajo
2
210
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
920
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Fireside Chat
paigeccino
37
3.5k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
20
1.3k
Six Lessons from altMBA
skipperchong
28
3.8k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
Rails Girls Zürich Keynote
gr2m
94
14k
Designing Experiences People Love
moore
142
24k
Gamification - CAS2011
davidbonilla
81
5.3k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
20k
GitHub's CSS Performance
jonrohan
1031
460k
Facilitating Awesome Meetings
lara
54
6.4k
Transcript
Parallel Universes Reader & Coreader for Dependency Injection Ì INCL.
COMONADS, MONADS & THE DISTANT PAST Elmar Kretzer @elmkretzer
- talk to network - use Date() - persist data
Does your app even: - you name it Why care?
HOW TO? ... wire it together? ... test it peacefully?
... set it up?
highly flexible duplication of code mental overhead error prone Keep
It Pass On 1 2
3 OPTIONS: „DO IT MANUALLY“ „USE A FRAMEWORK“ „DO SOMETHING
ELSE“
Let’s talk about „something else“ Functional Programming Weirder names for
weird concepts. Some/None/Few/All people like it.
But Swift does use/allow/force functional patterns. Sometimes you don’t even
notice. Swift Guess who’s not a Functional PL:
empowered by fp
FP & DI – Cool & How?
http://hackage.haskell.org/package/mtl-1.1.0.2/docs/Control-Monad-Reader.html „Represents a computation, which can read values from a
shared environment, pass values from function to function, and execute sub-computations in a modified environment.“ 1/2 READER MONAD
very abstract return sth. based on sth. else afterwards pass
it on to get sth. that itself returns sth. based on sth. else
Describe dependent operations. Provide How at the end. 100 +
10 + 5 + 2 100 * 10 * 5 * 2 100 - 10 - 5 - 2 100 / 10 / 5 / 2
„In more technical language the Reader comonad is left adjoint
to the Reader monad.“ 2/2 READER COMONAD https://hackage.haskell.org/package/category-extras-0.53.0/docs/Control-Comonad-Reader.html
very co-abstract hold sth. and sth. else afterwards get sth.
new from sth. and sth. else and return the new with sth. else
Describe dependent access. Provide from WHAT at the end. RealWorld
-> Api -> Server -> Time MockWorld - > Api -> Server -> Time
Reader vs Coreader Comonad extend M a -> M a
-> b -> M b Produce -> Consume Cokleisli Monad flatMap M a -> a -> M b -> M b Consume -> Produce Kleisli
Coreader No. B/C Controller, Storyboards and so forth. Reader Yes.
No one is holding you back. Worth it & simple to use in iOS?
What do you do? Corridor µFramework for a Coreader-like
access to dependencies. Combined with Reader: full-fledged control. github.com/symentis/Corridor
Pro? Unified Handling of DI. No business code for passing
on Dependencies. Dependencies are transparent. Testing simply takes different Environments. Less code. More safety.
Follow-Up article including gists on: http://elm4ward.github.io/ Corridor on GitHub: https://github.com/symentis/Corridor
Me on Twitter: @elmkretzer thanks for your time!