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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
machu
October 25, 2018
Technology
96
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
79
Authorization to implement with Extensible Effect
machuz
0
480
アルプの 認証/認可分離戦略と手法
machuz
3
820
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
国際カードブランドルール変更に伴うクレジットカード決済取引仕様変更について
k1style
0
270
Obsidian Vault Architectures
x5gtrn
PRO
0
210
AI時代の開発はウォーターフォールに回帰する? / development-with-ai-back-to-wf
okamototakuyasr2
0
160
200人の配信コメント、 全部Jevが仕分けます 〜 マサカリガードを作ってみた 〜
katayamatg
1
460
2拠点SRE活動始めてみた | sogaoh's LT @ ホンマでっかSRE勉強会 #3
sogaoh
PRO
0
210
増え続けるプロダクトの品質をどう担保するか。ProductSpecとTypeScriptによる取り組み
joere
2
240
ひとりで始めた AI駆動開発、チームに広げて何が変わったのか
kenichiodo
1
160
AIエージェント時代、Kaggleにどう取り組むか
takanao
2
430
Vibe-to-Spec開発_実践ガイド
happysamurai294
0
130
AIに任せられるFlutterコードベースを作る 〜仕様をコードで表し、ハーネスで守る〜
myohei
1
580
Don't write the architecture only in the prompt.
neohsu
0
270
re:Inventで、人生は変わったのか? / growth-builders-hub-1-reinvent-2026
mhrtech
2
170
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Paper Plane (Part 1)
katiecoart
PRO
2
12k
Paper Plane
katiecoart
PRO
5
54k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
What does AI have to do with Human Rights?
axbom
PRO
1
2.5k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
590
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
59k
Thoughts on Productivity
jonyablonski
76
5.4k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
470
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
Utilizing Notion as your number one productivity tool
mfonobong
4
630
WENDY [Excerpt]
tessaabrams
14
40k
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˒