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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Tim McGilchrist
May 24, 2018
Programming
0
150
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
180
Code reuse through polymorphic variants
lambda_foo
1
220
Idris States: Dependent types, not just for vectors?
lambda_foo
0
230
RAFT: Implementing Distributed Consensus with Erlang
lambda_foo
4
690
Other Decks in Programming
See All in Programming
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
230
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
130
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
250
Oxlintはいいぞ
yug1224
5
1.3k
CSC307 Lecture 08
javiergs
PRO
0
670
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
20
6.7k
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.3k
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
170
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
CSC307 Lecture 06
javiergs
PRO
0
680
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
370
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
5.9k
Featured
See All Featured
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
130
New Earth Scene 8
popppiees
1
1.5k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
210
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
730
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
300
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Typedesign – Prime Four
hannesfritz
42
2.9k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
3.9k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
240
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
410
A Tale of Four Properties
chriscoyier
162
24k
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