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
Either Error Success
Search
Tim McGilchrist
May 24, 2018
Programming
0
100
Either Error Success
Tim McGilchrist
May 24, 2018
Tweet
Share
More Decks by Tim McGilchrist
See All by Tim McGilchrist
Dependently Typed State Machines
lambda_foo
0
130
Code reuse through polymorphic variants
lambda_foo
1
120
Idris States: Dependent types, not just for vectors?
lambda_foo
0
160
RAFT: Implementing Distributed Consensus with Erlang
lambda_foo
4
640
Other Decks in Programming
See All in Programming
APIのない大学ログインWebサービスをWKWebViewとJavaScriptでアプリ化した話
akidon0000
1
330
Rust.Nagoya #1
codemountains
0
170
Trial
cairolibrary720
1
130
日付と正規化
megmogmog1965
0
140
しくじり先生 Image Matching Challenge 2024 編
goosehaaan
0
810
Async Await: Mastering Python's Time-Bending Tricks - EuroPython2024
yanbo
1
290
Terraformテスト入門
msato
0
540
3 Effective Rules for Success with Signals in Angular
manfredsteyer
PRO
0
120
わかりやすい正解を捨てて、コトに向き合う - スクラムフェス金沢2024 スポンサーセッション
yusukekokubo
0
170
開発部に不満を持っていたCSがエンジニアにジョブチェンしてわかった「勝手に諦めない」ことの大切さ
sakuraikotone
28
16k
みんなのオブザーバビリティプラットフォームを作ってるんだがパフォーマンスがやばい #mackerelio #srenext
ne_sachirou
0
380
君たちはどうコードをレビューする (される) か / 大吉祥寺.pm
utgwkk
15
8.5k
Featured
See All Featured
Leading Effective Engineering Teams 2024
addyosmani
3
300
The Invisible Customer
myddelton
117
13k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
18
1.2k
Building Effective Engineering Teams - LeadDev
addyosmani
47
2.2k
The World Runs on Bad Software
bkeepers
PRO
63
11k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
52k
Product Roadmaps are Hard
iamctodd
PRO
48
10k
Six Lessons from altMBA
skipperchong
24
3.2k
Building Adaptive Systems
keathley
34
2k
Unsuck your backbone
ammeep
666
57k
The MySQL Ecosystem @ GitHub 2015
samlambert
248
12k
Documentation Writing (for coders)
carmenintech
63
4.2k
Transcript
None
Either Error Success FP-SYD 2018
Introduction • who, what, why, where, how questions • who
-> Tim McGilchrist @lambda_foo • what -> exciting area of error handling • where -> in Haskell mostly • how -> with functions and data types
–Mark H “I have people sitting around solutionizing”
Examples • Code
–Nick H “I will admit human error played a large
part”
The Async Problem • Asynchronous exceptions are a feature of
Haskell • No fancy effect systems or modular IO effects • Deal with it! • Code in IO can fail at any point with an exception
Exception Pattern • Code
Exception Pattern • type signature doesn’t indicate errors • exceptions
compose without effort • no stack traces by default • dealing with exceptions properly is hard
EitherT Pattern • Code
EitherT Pattern • pattern matching has your back • composition
is explicit (you need to think) • application stack traces • constrained exception handling • extra work • interfacing with exception heavy code
Transformers Either • Code
Either Examples • mismi - wrapper around Amazonka • mafia
- cabal build tool • boris - continuous integration / builds
Exception Examples • http-client - http library • stack -
Haskell build tool ++ • hs-tls - Native Haskell TLS / SSL implementation
Conclusion • make error behaviour explicit • use appropriate tool
for the job • EitherT yields more maintainable code • similar or less effort to exceptions
Resources • https://simonmar.github.io/posts/2017-01-24- asynchronous-exceptions.html • https://haskell-lang.org/library/safe-exceptions • https://www.fpcomplete.com/blog/2016/11/exceptions- best-practices-haskell •
https://simonmar.github.io/bib/papers/async.pdf