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
130
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
160
Code reuse through polymorphic variants
lambda_foo
1
190
Idris States: Dependent types, not just for vectors?
lambda_foo
0
200
RAFT: Implementing Distributed Consensus with Erlang
lambda_foo
4
670
Other Decks in Programming
See All in Programming
AIエージェント開発、DevOps and LLMOps
ymd65536
1
360
あなたとJIT, 今すぐアセンブ ル
sisshiki1969
1
750
開発チーム・開発組織の設計改善スキルの向上
masuda220
PRO
17
9.2k
ソフトウェアテスト徹底指南書の紹介
goyoki
1
120
250830 IaCの選定~AWS SAMのLambdaをECSに乗り換えたときの備忘録~
east_takumi
0
330
モバイルアプリからWebへの横展開を加速した話_Claude_Code_実践術.pdf
kazuyasakamoto
0
290
Google I/O recap web編 大分Web祭り2025
kponda
0
2.9k
CSC305 Summer Lecture 12
javiergs
PRO
0
130
Oracle Database Technology Night 92 Database Connection control FAN-AC
oracle4engineer
PRO
1
310
KessokuでDIでもgoroutineを活用する / Go Connect #6
mazrean
0
120
Improving my own Ruby thereafter
sisshiki1969
1
130
tool ディレクティブを導入してみた感想
sgash708
1
150
Featured
See All Featured
Balancing Empowerment & Direction
lara
3
600
Optimising Largest Contentful Paint
csswizardry
37
3.4k
How STYLIGHT went responsive
nonsquared
100
5.8k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.5k
Scaling GitHub
holman
463
140k
The Pragmatic Product Professional
lauravandoore
36
6.8k
Writing Fast Ruby
sferik
628
62k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.7k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.8k
Art, The Web, and Tiny UX
lynnandtonic
302
21k
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