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
110
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
140
Code reuse through polymorphic variants
lambda_foo
1
140
Idris States: Dependent types, not just for vectors?
lambda_foo
0
160
RAFT: Implementing Distributed Consensus with Erlang
lambda_foo
4
650
Other Decks in Programming
See All in Programming
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
120
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
190
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
280
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
880
役立つログに取り組もう
irof
28
9.6k
as(型アサーション)を書く前にできること
marokanatani
9
2.6k
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
150
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
38
7.1k
The Language of Interfaces
destraynor
154
24k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Faster Mobile Websites
deanohume
305
30k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
Automating Front-end Workflow
addyosmani
1366
200k
RailsConf 2023
tenderlove
29
900
Scaling GitHub
holman
458
140k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
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