shithub: MicroHs

Download patch

ref: 4351551503d2e4db1d53d0f0f321341f91a9eb79
parent: 52088bbfd240e01c2bd172504df1920853f5538b
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Sat Feb 10 13:35:31 EST 2024

Add onException

--- a/lib/Control/Exception.hs
+++ b/lib/Control/Exception.hs
@@ -3,6 +3,7 @@
   throwIO,
   Exn(..),
   exnToString,
+  onException,
   ) where
 import Primitives
 import Prelude
@@ -22,3 +23,7 @@
 throwIO (Exn s) =
   let e = error s
   in  seq e (return e)
+
+onException :: IO a -> IO b -> IO a
+onException io what = io `catch` \e -> do _ <- what
+                                          throwIO e
--