The Semantics of Asynchronous Exceptions
-
Upload
don-stewart -
Category
Documents
-
view
218 -
download
0
Transcript of The Semantics of Asynchronous Exceptions
![Page 1: The Semantics of Asynchronous Exceptions](https://reader031.fdocuments.in/reader031/viewer/2022021322/577d38d31a28ab3a6b988e97/html5/thumbnails/1.jpg)
8/14/2019 The Semantics of Asynchronous Exceptions
http://slidepdf.com/reader/full/the-semantics-of-asynchronous-exceptions 1/8
Semantics of AsynchronousExceptions
![Page 2: The Semantics of Asynchronous Exceptions](https://reader031.fdocuments.in/reader031/viewer/2022021322/577d38d31a28ab3a6b988e97/html5/thumbnails/2.jpg)
8/14/2019 The Semantics of Asynchronous Exceptions
http://slidepdf.com/reader/full/the-semantics-of-asynchronous-exceptions 2/8
© 2010 Galois, Inc. All r ights reserved.
Conventions and Notations
Primitive IO actions are considered “values” for the purely functional part of thesemantics (>>=, putChar, block etc)
Evaluation contexts are assumed to be maximal
• F = [.] | F >>= M | catch F H
• E = F | F [ block E ] | F [ unblock E ]
Threads can be:
• Stuck: ( … )•
• Runnable: ( … )o
![Page 3: The Semantics of Asynchronous Exceptions](https://reader031.fdocuments.in/reader031/viewer/2022021322/577d38d31a28ab3a6b988e97/html5/thumbnails/3.jpg)
8/14/2019 The Semantics of Asynchronous Exceptions
http://slidepdf.com/reader/full/the-semantics-of-asynchronous-exceptions 3/8
© 2010 Galois, Inc. All r ights reserved.
IO Primitives
![Page 4: The Semantics of Asynchronous Exceptions](https://reader031.fdocuments.in/reader031/viewer/2022021322/577d38d31a28ab3a6b988e97/html5/thumbnails/4.jpg)
8/14/2019 The Semantics of Asynchronous Exceptions
http://slidepdf.com/reader/full/the-semantics-of-asynchronous-exceptions 4/8
© 2010 Galois, Inc. All r ights reserved.
Threads and Exceptions
![Page 5: The Semantics of Asynchronous Exceptions](https://reader031.fdocuments.in/reader031/viewer/2022021322/577d38d31a28ab3a6b988e97/html5/thumbnails/5.jpg)
8/14/2019 The Semantics of Asynchronous Exceptions
http://slidepdf.com/reader/full/the-semantics-of-asynchronous-exceptions 5/8
© 2010 Galois, Inc. All r ights reserved.
Basic Transitions
![Page 6: The Semantics of Asynchronous Exceptions](https://reader031.fdocuments.in/reader031/viewer/2022021322/577d38d31a28ab3a6b988e97/html5/thumbnails/6.jpg)
8/14/2019 The Semantics of Asynchronous Exceptions
http://slidepdf.com/reader/full/the-semantics-of-asynchronous-exceptions 6/8
© 2010 Galois, Inc. All r ights reserved.
Asynchronous Exceptions
![Page 7: The Semantics of Asynchronous Exceptions](https://reader031.fdocuments.in/reader031/viewer/2022021322/577d38d31a28ab3a6b988e97/html5/thumbnails/7.jpg)
8/14/2019 The Semantics of Asynchronous Exceptions
http://slidepdf.com/reader/full/the-semantics-of-asynchronous-exceptions 7/8
![Page 8: The Semantics of Asynchronous Exceptions](https://reader031.fdocuments.in/reader031/viewer/2022021322/577d38d31a28ab3a6b988e97/html5/thumbnails/8.jpg)
8/14/2019 The Semantics of Asynchronous Exceptions
http://slidepdf.com/reader/full/the-semantics-of-asynchronous-exceptions 8/8
© 2010 Galois, Inc. All r ights reserved.
Higher-level Operators
onException :: IO a -> IO b -> IO aonException io what
= io `catch` (\e -> what >> throw (e :: SomeException))
finally :: IO a -> IO b -> IO aa `finally` sequel = block $ do
r <- unblock a `onException` sequelsequelreturn r
try :: Exception e => IO a -> IO (Either e a)try a = (a >>= (return . Right)) `catch` (return . Left)