Upgrade to Pro — share decks privately, control downloads, hide ads and more …

let_s_use_Eff.pdf

C6a8cb5e13aa716521d522471ec4e4cd?s=47 ma2k8
November 08, 2018

 let_s_use_Eff.pdf

C6a8cb5e13aa716521d522471ec4e4cd?s=128

ma2k8

November 08, 2018
Tweet

Transcript

  1. let's use Eff ~first step~

  2. ࠓ೔͸ ΄Μͷ͞ΘΓ͚ͩͰ͢

  3. ༻ޠͷઆ໌ • Monad Transformer • Extensible effect (use FreeMonad) •

    ˒Freer effects (use FreerMonad, Efficient Freer) • ࠓճಋೖ͢Δͷ͸Freer effectsɻ͜·͍࿩͸ผͰࢿྉ࡞ͬͯ෦ձͰͰ΋࿩͠·͢ɻ
  4. effͰͳʹ͕͍ͨ͠ͷ͔ • DSLΛ࡞ͬͯͦΕΛ߹੒͍ͨ͠ɻ • DSL͸ӳޠαϓϦDSLతͳ୯ҐͰ࡞ΔͱυϝΠϯ͕Ͱ͔͗ͯ͋͢·Γҙຯ͕ͳ͍ • ࡉ͔͍୯ҐͰDSLΛ࡞ΓɺͦΕΛUseCaseͰ߹੒͢Ε͹υϝΠϯ͕๲Β·ͳ͍ • DSLΛ࡞Δ·Ͱ΋ͳ͍ࡉ͔ͳEffect΋߹੒͍ͨ͠ •

    zipkinͰͷτϨʔε΍ॲཧͷϕϯνϚʔΫ౳ɺΞϓϦέʔγϣϯίʔυ΁ͷมߋ͕ඞཁͳٕज़Ҋ݅Λ͢͹΍ ҆͘શʹߦ͏͜ͱ͕Ͱ͖Δɻ • ※͜͜Ͱ͍͏DSL͸શͯEDSLͰ͢ɻ
  5. Ͳ͏มΘΔͷ͔ SecondaryAdapter૚ UseCase૚ Domain૚ Application૚ ※ґଘੑٯసޙͷਤͰ͢ ·ͣ͸͜͜ʹDSL,InterpreterΛ ಋೖ͢Δɻ Lib૚ ࢖͍·Θ͠Մೳͳ෦඼͸͜͜΁

  6. ίʔυͷΠϝʔδ

  7. DSL • ͜Μͳײ͡ͷܕ(ADT)͕Ͱ͖·͢ɻ • store,find,delete,exists,clear͸Monad Stack΁ૢ࡞ΛੵΉεϚʔτίϯετϥΫλͰ͢ɻҰݟ೉ͦ͠͏Ͱ͕࢖͏ͱ͖͸؆୯ͳͷͰ҆͝৺Λ(ޙड़)

  8. Interpreter • ఆٛͨ͠ADTΛύλʔϯϚονͯ͠ॲཧΛ͢Δɻ • ͜͜Ͱ΋৭ΜͳEffectΛ߹੒͢Δ͜ͱ͕Ͱ͖Δɻ

  9. ࣮ߦ • InterpreterͷςετΛషͬͯΈΔ • ͜ͷςετ͸௨Γ·͢ɻ • CacheIOͷதͰ͸writer,reader,either,taskΛ߹੒͍ͯ͠Δͷ ʹɺprogram಺Ͱ͸΄ͱΜͲҙࣝ͠ͳ͍ͰOK • ࣮ߦ࣌ʹͲͷEffectΛ͍ࠞͥͯΔ͔͚ͩڭ͑ͯ͋͛ͳ͍ͱ͍

    ͚ͳ͍͕ɺࡉ͔͘ҙࣝ͠ͳ͍ͰॅΉΑ͏ʹ͢Δ༧ఆ (CacheIO,TwilioIOͷελοΫΛ͕ͬͪΌΜͯ͜͠Θͨͩ͢ ͚ɺ͘Β͍ͷཻ౓ɻ
  10. ΋͏গ͠༡ΜͰΈΑ͏ • ಠࣗఆٛͷDSLͱ͸ผͰtaskܕͱUnitܕ΋ࠞͥͯΈΔɻ • ͜Ε΋ී௨ʹ௨Δɻ • ܕ߹ΘͤήʔϜ͕΋ͷ͘͢͝γϯϓϧʹͳ͍ͬͯΔͷ͕͓Θ͔Γ͍͚ͨͩΔͩΖ͏͔ɾɾɾɾɾ • sequence΋Eff.SequenceAͰ༻ҙ͞Ε͍ͯΔɻࠓ࢖ͬͯΔ΋ͷ͸Χόʔ͍ͯ͠Δɻ

  11. ࢒Γ࡞ۀήʔ͜ͳͤ͹ PRͰΔͷͰ΋͏ͪΐ͍͓଴ͪΛ