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
130
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
React + TextAliveでカッコいいLyric Applicatioinを作ろう!!
tosuri13
0
400
マイグレーションコード自作して File-Based Routing に自動移行!! ~250 ページの歴史的経緯を添えて~
cut0
1
260
AndroidアプリのUIバリエーションをあの手この手で確認する / Check UI variations of Android apps by various means
tkmnzm
1
130
1人で挑むSwiftコンパイラ 〜型システム入門編〜
s_shimotori
0
340
Rustではじめる負荷試験
skanehira
5
1.2k
いつか使える ObjectSpace / Maybe useful ObjectSpace
euglena1215
2
130
unique パッケージから学ぶ interning と weak reference @ Asakusa.go#3
karamaru
2
780
Method Swizzlingを行うライブラリにおけるマルチモジュール設計
yoshikma
0
110
状態管理ライブラリZustandの導入から運用まで
k1tikurisu
3
460
What you can do with Ruby on WebAssembly
kateinoigakukun
0
160
Our Websites Need a Lifestyle Change, Not a Diet
ryantownsend
0
140
Some more adventure of Happy Eyeballs
coe401_
2
180
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
48
4.6k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
43
2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
How to name files
jennybc
75
98k
Designing for Performance
lara
604
68k
Web Components: a chance to create the future
zenorocha
308
42k
Product Roadmaps are Hard
iamctodd
PRO
48
10k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
157
15k
How to train your dragon (web standard)
notwaldorf
85
5.6k
Into the Great Unknown - MozCon
thekraken
29
1.4k
Visualization
eitanlees
142
15k
Speed Design
sergeychernyshev
22
430
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