Last active
October 6, 2024 13:37
-
-
Save Hogeyama/140d0d78c684d6757619ef04580ecdd7 to your computer and use it in GitHub Desktop.
MonadUnliftIO (ExceptT e m)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- [Control.Monad.IO.Unlift](https://hackage.haskell.org/package/unliftio-core-0.2.1.0/docs/Control-Monad-IO-Unlift.html#t:MonadUnliftIO) | |
| -- 定義はできるがInverse lawが成り立たないのでダメ | |
| -- withRunInIO (\_ -> throwIO e) === liftIO (throwIO e) | |
| -- にならないといけないが、pure (Left e)になってしまう。 | |
| -- たぶんjoinの保存則も成り立たないんじゃないかな。 | |
| -- | |
| -- あと、askUnliftIOを使うとtryのスコープを抜けてしまって酷いバグになりそう。 | |
| -- askUnliftIO = withRunInIO (\run -> return (UnliftIO run)) | |
| instance (MonadUnliftIO m, Exception e) => MonadUnliftIO (ExceptT e m) where | |
| withRunInIO inner = | |
| ExceptT $ | |
| withRunInIO @m \unlift -> try $ | |
| inner \m -> | |
| unlift (runExceptT m) >>= \case | |
| Left e -> throwIO e | |
| Right b -> pure b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment