Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Eff HandsOn
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
machu
October 25, 2018
Technology
95
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Eff HandsOn
machu
October 25, 2018
More Decks by machu
See All by machu
NBAチームから学ぶ強いチームの作り方
machuz
0
77
Authorization to implement with Extensible Effect
machuz
0
470
アルプの 認証/認可分離戦略と手法
machuz
3
810
AuthzCtx - Alp社内共有会
machuz
0
110
アルプのEff独自エフェクト集 / Alp-original ’Eff’ pearls
machuz
1
2.3k
Scalebaseバックエンド構成について/the backend design of Scalebase
machuz
0
6.6k
SQL Meisterへの道 ~更新編~ / sql-meister-CUD
machuz
0
2.4k
SQL Meisterへの道 ~基礎〜参照編~ / sql-meister-R
machuz
0
2.8k
Authz
machuz
0
330
Other Decks in Technology
See All in Technology
なぜ「決定性」が 決定的に重要なのか? Durable Execution 基盤の数理的理解 #serverlessjp / ServerlessDays Tokyo 2026
ytaka23
1
390
SREは、MCPとAutopilotをこう使え!
kazumax55
3
870
バイブコーディング時代のWebアプリ開発入門~Cloud Runで学ぶセキュアなビルドとデプロイ
waiwai2111
1
130
あけおめLINE 傾向とその対策
nasa9084
0
110
AIエージェントの一手は 誰も見ていない - Falco拡張OSS「Prempti」とeBPFで サーバーレス実行基盤を二層防御する
keitah
0
120
2026-09-18 gotanda.sre Terraformで複数環境作ったり、複数Stateに分割したりそれとTerragrunt / Terraform multi envs and multi states
masasuzu
2
460
AI時代の「技術的負債」の変質ー概念の終焉と再解釈、エージェントと共に向かう先
nwiizo
1
2.8k
AIを活用するために決めた "やらないこと" - 価値に注目する / Not betting on AI
soudai
PRO
2
550
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
12k
Genieを崇めよ
kameitomohiro
0
160
AI de Idea
kawaguti
PRO
2
120
Reactの設計論
uhyo
24
13k
Featured
See All Featured
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.8k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.9k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
410
30 Presentation Tips
portentint
PRO
1
400
Done Done
chrislema
186
16k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
280
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
990
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Designing for Timeless Needs
cassininazir
1
480
New Earth Scene 8
popppiees
4
2.6k
Transcript
Eff hands on
༻ޠͷઆ໌ • Monad Transformer • Extensible effect (use FreeMonad) •
˒Freer effects (use FreerMonad, Efficient Freer) • جͷจͰ more Extensible effectͱݺΜͰ͍Δ
Ϟφτϥͱͷൺֱ(ࡶ)
߹ͷॱং • ϞφυτϥϯεϑΥʔϚʔ߹ͷॱংΛೖΕସ͑Δ͜ͱ ͕Ͱ͖ͳ͍ • EffOpenUnionʹΑͬͯՄೳ
࡞༻ͷॱং • ϞφυτϥϯεϑΥʔϚʔධՁॱΛೖΕସ͑Δͱ݁Ռ͕ มΘΔ • EffมΘΒͳ͍(Writer,Eitherɺܕʹ࡞༻͢Δͷ ී௨ʹॱংʹΑͬͯܕมΘΔ͕ܭࢉͷ݁ՌมΘΒͳ͍ • ʹαϯϓϧίʔυ͕͋Δ(Haskell͚ͩͲɾɾɾ) •
https://konn-san.com/prog/haskell/extensible-effects.html
ωετπϥΠͶΜ • EnglishͰ`Future[\/[E, A]]` ΛҾ͖ճ͢Α͏ʹ͠ɺͦΕҎ্ ͷෳࡶͳܕͳΔ͘Θͳ͍Α͏ʹͯ͠ճආ͍ͯ͠Δ͕ɺ 3ͭҎ্ͷϞφυΛ߹͢Δ߹liftͰ্࣋ͪ͛ͯॲཧ͢ Δඞཁ͕͋ΔɻৗʹίϯςΩετΛҙࣝ͠ͳ͍ͱ͍͚ͣɺ ਓྨͷΈͦʹͱͯΉ͔͍ͣ͠ •
EffͰશͯϑϥοτͳforࣜͰճͤΔɻωετ͠ͳ͍ɻ
ॏ͍ • Ϟφτϥɻܕ߹ΘͤͷͨΊʹ༨ܭͳ࡞ΒΕΔ • Future[\/[E,A]] • Future[\/[E,Future[\/[E, A]]]] • Future[\/[E,Future[\/[E,
Future[\/[E, A]]]]]] • (Θ͔Γ͘͢ಉ͡ܕʹͨ͠ͷͰਖ਼֬Ͱͳ͍͕)Έ͍ͨͳײ͡Ͱελο Ϋ͍ͯ͘͠ɻੵΊੵΉ΄Ͳॏ͍ • EffOpenUnion,EfficientFreerʹΑͬͯελοΫͷʹґଘ ͠ͳ͍ఆ࣌ؒͰͷॲཧ͕Մೳ
͍ํ
ͯ͢EffʹͳΔ • ͍··ͰM[+_]ίϯςΩετͷதͰ`.right`ͯ͠`toEitherT`͠ ͍ͯͨͷ͕ͯ͢EffʹͳΔ • Future,Either,DBIO,Reader,Writer,Taskɺͯ͢ͷMonadEff ม͢Δ͜ͱ͕Ͱ͖Δ • ࠓͷॴɺOptionͱTraversalܥ(List,Seq)Ҏ֎ΛEffʹ͢ΔΑ ͏ʹ͍ͯ͠Δ
͜ͷΜΛimport import org.atnos.eff.Eff import org.atnos.eff.syntax.all._ import org.atnos.eff.addon.scalaz.either._ import org.atnos.eff.addon.monix.task._ import
jp.eigosapuri.es.shared.lib.eff.either.EsErrorEffect._ import jp.eigosapuri.es.shared.adapter.secondary.eff._ import jp.eigosapuri.es.shared.adapter.secondary.eff.push.PushIOEffect._ import jp.eigosapuri.es.shared.adapter.secondary.eff.db.DBIOEffect._
͜Μͳײ͡ͰEffԽ override def resolveById[R: _dbio]( id: CallPreparationId )(implicit ec: ExecutionContext):
Eff[R, Option[CallPreparation]] = { for { resOpt <- fromDBIO(callPreparationStatusesDAO.ioFindById(id.value)) } yield resOpt.map(convertToDomainModel) } fromDBIOͰEffԽ͍ͯ͠Δ
؆୯ʹΈ͑Δ͔͕ͩ ͜ΕΊͬͪΌࣗ༝ߴ͍
for { x <- Option(7) y <- DBIO.successful(x) _ <-
-\/(UseCaseError) } y ཁҧ͏ܕͷ߹͕࣮ݱͰ͖͍ͯΔ for { x <- fromOption(Option(7)) y <- fromDBIO(DBIO.successful(x)) _ <- fromEsError(-\/(UseCaseError)) } y
ࠓޙɺFujiTaskΛՃ͍ͯ͘͠
ҙ
• ܕ߹Θͤήʔ͔Β։์͞Ε͍ͯ·͕͢ɺ·ͩཧͰ͖ͯ ͳͯ͘importήʔʹͳ͍ͬͯΔ • ࡞༻ͷλάͷཧ͕Ͱ͖͍ͯͳ͍
importήʔ • EffܥͷύοέʔδΛimport͠ͳ͍ͱ͍͚ͳ͍ • ScalazɺxxExtensionͱಉ͡ϊϦͰ͢ • ͏ͪΐ͍ཧͯ͠ҰՕॴimport͢Ε͕͍ͯͭͯ͘͢ΔΑ͏ʹ͠·͢ • ۩ମతʹҎԼͷύοέʔδ import
org.atnos.eff.Eff import org.atnos.eff.syntax.all._ import org.atnos.eff.addon.scalaz.either._ import org.atnos.eff.addon.monix.task._ import jp.eigosapuri.es.shared.lib.eff._ import jp.eigosapuri.es.shared.lib.eff.cache.CacheIOTypes._ import jp.eigosapuri.es.shared.lib.eff.push.PushIOTypes._ import jp.eigosapuri.es.shared.lib.eff.util.clock.joda.JodaTimeMEffect._ import jp.eigosapuri.es.shared.lib.eff.util.idGen.IdGenEffect._ import jp.eigosapuri.es.shared.lib.eff.either.EsErrorEffect._ import jp.eigosapuri.es.shared.adapter.secondary.eff._ import jp.eigosapuri.es.shared.adapter.secondary.eff.push.PushIOEffect._ import jp.eigosapuri.es.shared.adapter.secondary.eff.db.DBIOEffect._ import jp.eigosapuri.es.shared.adapter.secondary.eff.push.CacheIOInterpretationTypes._ import jp.eigosapuri.es.shared.adapter.secondary.eff.cache.interpreter.CacheIOInterpreter import jp.eigosapuri.es.shared.adapter.secondary.eff.db.interpreter.DBIOInterpreter import jp.eigosapuri.es.shared.adapter.secondary.eff.push.interpreter.PushIOInterpreter
࡞༻λάᶃ • EffͰͲͷ࡞༻ΛؚΉ͔Λࢦఆ͢Δඞཁ͕͋Δ • ྫ͑ɺDBIOͱIdGen,JodaTime,PushΛར༻͢Δ߹ type R = FxAppend[DBIOStack, FxAppend[ModelApplyStack,
PushIOStack]] • ͦΕͧΕͷத type DBIOStack = Fx.fx3[DBIO, Task, ErrorEither] type ModelApplyStack = Fx.fx2[IdGen, JodaTimeM] type PushIOStack = Fx.fx1[PushIO] • ͜ͷΑ͏ʹ͋Δఔͷ୯ҐͰ·ͱΊΒΕͨStackΛFxAppendͰ͕ͬͪΌΜ͜ Ͱ͖ΔɻޙͷΑ͏ʹUseCaseʹ࣮ͯ͠ߦ͢Δ͚ͩ startCallUseCase.execute[R](arg) • ಉ͡λάΛෳࢦఆ͢Δ͜ͱͰ͖ͳ͍
࡞༻λάᶄ • ࢦఆͨ͠λά(࡞༻)ΛҰͭҰͭධՁ͍ͯ͘͠ɻ • DBIOStack, ModelApplyStack, PushIOStackͷධՁҎԼͷΑ͏ʹͳΔ useCaseRes.runTransactionDBIO .runIdGen .runJodaTimeM
.runPushIO .runEsError .runAsync .runAsync .map(startCallPresenter.response) • ͜Ε `run` ͚ͩͰࡁΉΑ͏࣮ݧத
࡞༻λάᶅ • ͜ͷλάؔͷγάχνϟͱͯ͠Ҿ͖ճ͞ͳ͍ͱ͍͚ͳ ͍ def execute[R: _dbio: _task: _errorEither: _pushio:
_idgen: _jodaTimem]( arg: StartCallUseCaseArgs )(implicit ec: ExecutionContext): Eff[R, StartCallUseCaseResult]
͜ΕΒमਖ਼தͰ͢
˒YATTEIKI˒