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
120
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
160
Code reuse through polymorphic variants
lambda_foo
1
180
Idris States: Dependent types, not just for vectors?
lambda_foo
0
190
RAFT: Implementing Distributed Consensus with Erlang
lambda_foo
4
670
Other Decks in Programming
See All in Programming
WindowInsetsだってテストしたい
ryunen344
1
200
Kotlin エンジニアへ送る:Swift 案件に参加させられる日に備えて~似てるけど色々違う Swift の仕様 / from Kotlin to Swift
lovee
1
260
#QiitaBash MCPのセキュリティ
ryosukedtomita
0
470
PHP 8.4の新機能「プロパティフック」から学ぶオブジェクト指向設計とリスコフの置換原則
kentaroutakeda
2
680
Result型で“失敗”を型にするPHPコードの書き方
kajitack
4
540
deno-redisの紹介とJSRパッケージの運用について (toranoana.deno #21)
uki00a
0
160
Create a website using Spatial Web
akkeylab
0
310
童醫院敏捷轉型的實踐經驗
cclai999
0
200
Flutterで備える!Accessibility Nutrition Labels完全ガイド
yuukiw00w
0
120
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
210
システム成長を止めない!本番無停止テーブル移行の全貌
sakawe_ee
1
150
技術同人誌をMCP Serverにしてみた
74th
1
450
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
329
21k
Documentation Writing (for coders)
carmenintech
72
4.9k
How STYLIGHT went responsive
nonsquared
100
5.6k
Statistics for Hackers
jakevdp
799
220k
Docker and Python
trallard
44
3.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Scaling GitHub
holman
459
140k
Side Projects
sachag
455
42k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
4 Signs Your Business is Dying
shpigford
184
22k
Speed Design
sergeychernyshev
32
1k
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