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
86
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
120
Code reuse through polymorphic variants
lambda_foo
1
91
Idris States: Dependent types, not just for vectors?
lambda_foo
0
150
RAFT: Implementing Distributed Consensus with Erlang
lambda_foo
4
640
Other Decks in Programming
See All in Programming
⼤規模⾔語モデルの拡張(RAG)が 終わったかも知れない件について
nearme_tech
23
15k
SwiftUIで使いやすいToastの作り方 / How to build a Toast system which is easy to use in SwiftUI
lovee
3
140
デフォルトにして至高、RubyMineの大好きな所
ruzia
0
360
MicrosoftのPlatform Engineeringガイドを読んで実際になにかやってみた
ymd65536
1
330
0→1と1→10の狭間で Javaという技術選定を振り返る/Reflecting on the Decision to Choose Java Between Scaling from 0 to 1 and 1 to 10
jaguar_imo
2
380
Behind VS Code Extensions for JavaScript / TypeScript Linnting and Formatting
unvalley
5
920
GraphQLサーバの構成要素を整理する #ハッカー鮨 #tsukijigraphql / graphql server technology selection
izumin5210
4
840
単体テストを書かない技術 #phpcon_odawara
o0h
PRO
27
8.3k
Amazon SQSコンシューマー疎結合への旅 - 出張! #DevelopersIO IT技術ブログの中の人が語る勉強会 #3
quiver
0
270
try!Swift Tokyo 2024 参加報告 LT
akidon0000
1
220
MetricKitで予期せぬ終了を検知する話 / Detect unexpected termination with MetricKit
nekowen
1
190
Apache Hive 4 on Treasure Data
ryukobayashi
0
290
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
9
8.3k
Raft: Consensus for Rubyists
vanstee
132
6.3k
Building a Scalable Design System with Sketch
lauravandoore
456
32k
10 Git Anti Patterns You Should be Aware of
lemiorhan
648
58k
Being A Developer After 40
akosma
57
580k
Web development in the modern age
philhawksworth
202
10k
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
17
1.4k
How to Ace a Technical Interview
jacobian
272
22k
Product Roadmaps are Hard
iamctodd
44
9.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
320
23k
Debugging Ruby Performance
tmm1
70
11k
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