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
150
Idris States: Dependent types, not just for vectors?
lambda_foo
0
170
RAFT: Implementing Distributed Consensus with Erlang
lambda_foo
4
650
Other Decks in Programming
See All in Programming
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
2
3.8k
return文におけるstd::moveについて
onihusube
1
1.3k
Jakarta EE meets AI
ivargrimstad
0
280
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
180
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
3
490
MCP with Cloudflare Workers
yusukebe
2
230
Zoneless Testing
rainerhahnekamp
0
120
Spatial Rendering for Apple Vision Pro
warrenm
0
150
歴史と現在から考えるスケーラブルなソフトウェア開発のプラクティス
i10416
0
130
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
7
1.5k
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
260
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
350
Featured
See All Featured
Done Done
chrislema
182
16k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
We Have a Design System, Now What?
morganepeng
51
7.3k
Statistics for Hackers
jakevdp
796
220k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
The Cost Of JavaScript in 2023
addyosmani
46
7k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
A designer walks into a library…
pauljervisheath
205
24k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
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