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
150
Code reuse through polymorphic variants
lambda_foo
1
150
Idris States: Dependent types, not just for vectors?
lambda_foo
0
180
RAFT: Implementing Distributed Consensus with Erlang
lambda_foo
4
650
Other Decks in Programming
See All in Programming
dbt Pythonモデルで実現するSnowflake活用術
trsnium
0
290
SwiftUI移行のためのインプレッショントラッキング基盤の構築
kokihirokawa
0
190
もう少しテストを書きたいんじゃ〜 #phpstudy
o0h
PRO
21
4.4k
気がついたら子供が社会人になって 自分と同じモバイルアプリエンジニアになった件 / Parent-Child Engineers
koishi
0
130
Swift Testingのモチベを上げたい
stoticdev
2
220
Introduction to C Extensions
sylph01
3
130
Kotlinの開発でも AIをいい感じに使いたい / Making the Most of AI in Kotlin Development
kohii00
5
2.1k
メンテが命: PHPフレームワークのコンテナ化とアップグレード戦略
shunta27
0
340
高セキュリティ・高耐障害性・サブシステム化。そして2億円
tasukulab280
2
410
Go 1.24でジェネリックになった型エイリアスの紹介
syumai
2
320
Lambdaの監視、できてますか?Datadogを用いてLambdaを見守ろう
nealle
2
850
PEPCは何を変えようとしていたのか
ken7253
3
320
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
328
21k
Measuring & Analyzing Core Web Vitals
bluesmoon
6
270
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
227
22k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
4
400
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Being A Developer After 40
akosma
89
590k
Making the Leap to Tech Lead
cromwellryan
133
9.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
193
16k
Java REST API Framework Comparison - PWX 2021
mraible
29
8.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Automating Front-end Workflow
addyosmani
1369
200k
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