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
160
0
Share
Either Error Success
Tim McGilchrist
May 24, 2018
More Decks by Tim McGilchrist
See All by Tim McGilchrist
Dependently Typed State Machines
lambda_foo
0
190
Code reuse through polymorphic variants
lambda_foo
1
240
Idris States: Dependent types, not just for vectors?
lambda_foo
0
260
RAFT: Implementing Distributed Consensus with Erlang
lambda_foo
4
700
Other Decks in Programming
See All in Programming
SPMマルチモジュールで テストカバレッジを取得する技法
yosshi4486
0
120
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.1k
AI時代だからこそ「Bloc」を採用する価値があるのかもしれない
takuroabe
0
240
関係性から理解する"同一性"の型用語たち
pvcresin
2
580
Old Dog, New Tricks: The Java 25 Reinvention - JNation
bazlur_rahman
0
130
新規プロダクトを高速で生み出すハーネスエンジニアリング
seanchas116
7
2.3k
ECR拡張スキャンでSBOMを収集して サプライチェーン攻撃の影響調査を 爆速で終わらせてみた
akihisaikeda
2
200
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
330
OSもどきOS
arkw
0
220
AI Agent と正しく分析するための環境作り
yoshyum
3
610
Oxlintのカスタムルールの現況
syumai
4
530
AIとRubyの静的型付け
ukin0k0
0
140
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
290
エンジニアに許された特別な時間の終わり
watany
107
240k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1.1k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.3k
Code Reviewing Like a Champion
maltzj
528
40k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
Fireside Chat
paigeccino
42
3.9k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
BBQ
matthewcrist
89
10k
Making the Leap to Tech Lead
cromwellryan
135
9.8k
Typedesign – Prime Four
hannesfritz
42
3k
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