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
CursorとDevinが仲間!?AI駆動で新規プロダクト開発に挑んだ3ヶ月を振り返る / A Story of New Product Development with Cursor and Devin
rkaga
3
850
今話題のMCPサーバーをFastAPIでサッと作ってみた
yuukis
0
130
Golangci-lint v2爆誕: 君たちはどうすべきか
logica0419
1
260
ドメイン駆動設計とXPで支える子どもの未来 / Domain-Driven Design and XP Supporting Children's Future
nrslib
0
290
Bedrock × Confluenceで簡単(?)社内RAG
iharuoru
1
130
「理解」を重視したAI活用開発
fast_doctor
0
300
Beyond_the_Prompt__Evaluating__Testing__and_Securing_LLM_Applications.pdf
meteatamel
0
110
VitestのIn-Source Testingが便利
taro28
9
2.5k
一緒に働きたくなるプログラマの思想 #QiitaConference
mu_zaru
81
21k
Designing Your Organization's Test Pyramid ( #scrumniigata )
teyamagu
PRO
5
1.5k
The Nature of Complexity in John Ousterhout’s Philosophy of Software Design
philipschwarz
PRO
0
170
fieldalignmentから見るGoの構造体
kuro_kurorrr
0
140
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.5k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
32
5.6k
Building Adaptive Systems
keathley
41
2.5k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Code Reviewing Like a Champion
maltzj
523
40k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
The Cost Of JavaScript in 2023
addyosmani
49
7.8k
Visualization
eitanlees
146
16k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
Automating Front-end Workflow
addyosmani
1370
200k
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!