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
140
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
170
Code reuse through polymorphic variants
lambda_foo
1
210
Idris States: Dependent types, not just for vectors?
lambda_foo
0
220
RAFT: Implementing Distributed Consensus with Erlang
lambda_foo
4
680
Other Decks in Programming
See All in Programming
AI POSにおけるLLM Observability基盤の導入 ― サイバーエージェントDXインターン成果報告
hekuchan
0
590
Tangible Code
chobishiba
3
570
TVerのWeb内製化 - 開発スピードと品質を両立させるまでの道のり
techtver
PRO
3
1.1k
なぜ強調表示できず ** が表示されるのか — Perlで始まったMarkdownの歴史と日本語文書における課題
kwahiro
12
6k
Chart.jsで長い項目を表示するときのハマりどころ
yumechi
0
110
「10分以内に機能を消せる状態」 の実現のためにやっていること
togishima
1
440
Querying Design System デザインシステムの意思決定を支える構造検索
ikumatadokoro
1
1.1k
CloudflareのSandbox SDKを試してみた
syumai
0
160
Nitro v3
kazupon
2
310
知られているようで知られていない JavaScriptの仕様 4選
syumai
0
600
乱雑なコードの整理から学ぶ設計の初歩
masuda220
PRO
31
13k
Feature Flags Suck! - KubeCon Atlanta 2025
phodgson
0
130
Featured
See All Featured
KATA
mclloyd
PRO
32
15k
It's Worth the Effort
3n
187
28k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
192
56k
Speed Design
sergeychernyshev
32
1.2k
Six Lessons from altMBA
skipperchong
29
4.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
Automating Front-end Workflow
addyosmani
1371
200k
How to train your dragon (web standard)
notwaldorf
97
6.4k
Producing Creativity
orderedlist
PRO
348
40k
Code Reviewing Like a Champion
maltzj
527
40k
Unsuck your backbone
ammeep
671
58k
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