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
150
0
Share
Either Error Success
Tim McGilchrist
May 24, 2018
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
230
Idris States: Dependent types, not just for vectors?
lambda_foo
0
240
RAFT: Implementing Distributed Consensus with Erlang
lambda_foo
4
690
Other Decks in Programming
See All in Programming
Codex CLIのSubagentsによる並列API実装 / Parallel API Implementation with Codex CLI Subagents
takatty
2
860
安いハードウェアでVulkan
fadis
1
920
「効かない!」依存性注入(DI)を活用したAPI Platformのエラーハンドリング奮闘記
mkmk884
0
310
KagglerがMixSeekを触ってみた
morim
0
370
PDI: Como Alavancar Sua Carreira e Seu Negócio
marcelgsantos
0
100
事業会社でのセキュリティ長期インターンについて
masachikaura
0
230
Codex CLI でつくる、Issue から merge までの開発フロー
amata1219
0
330
Migration to Signals, Signal Forms, Resource API, and NgRx Signal Store @Angular Days 03/2026 Munich
manfredsteyer
PRO
0
240
実践CRDT
tamadeveloper
0
330
我々はなぜ「層」を分けるのか〜「関心の分離」と「抽象化」で手に入れる変更に強いシンプルな設計〜 #phperkaigi / PHPerKaigi 2026
shogogg
2
810
Linux Kernelの1文字のミスで 権限昇格ができた話
rqda
0
2.3k
メッセージングを利用して時間的結合を分離しよう #phperkaigi
kajitack
3
560
Featured
See All Featured
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
190
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
710
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
170
So, you think you're a good person
axbom
PRO
2
2k
A Soul's Torment
seathinner
5
2.6k
SEO for Brand Visibility & Recognition
aleyda
0
4.4k
Evolving SEO for Evolving Search Engines
ryanjones
0
170
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.5k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
260
The Invisible Side of Design
smashingmag
302
51k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
410
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