[Git][ghc/ghc][master] Fix example in GHC user guide in SafeHaskell section
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Tue Sep 5 04:39:27 UTC 2023
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00
Fix example in GHC user guide in SafeHaskell section
The example given in the SafeHaskell section uses an implementation of
Monad which no longer works. This MR removes the non-canonical return
instance and adds the necessary instances of Functor and Applicative.
- - - - -
1 changed file:
- docs/users_guide/exts/safe_haskell.rst
Changes:
=====================================
docs/users_guide/exts/safe_haskell.rst
=====================================
@@ -109,8 +109,14 @@ define the plugin interface so that it requires the plugin module,
-- Notice that symbol UnsafeRIO is not exported from this module!
newtype RIO a = UnsafeRIO { runRIO :: IO a }
+ instance Functor RIO where
+ fmap f (UnsafeRIO m) = UnsafeRIO (fmap f m)
+
+ instance Applicative RIO where
+ pure = UnsafeRIO . pure
+ (UnsafeRIO f) <*> (UnsafeRIO m) = UnsafeRIO (f <*> m)
+
instance Monad RIO where
- return = UnsafeRIO . return
(UnsafeRIO m) >>= k = UnsafeRIO $ m >>= runRIO . k
-- Returns True iff access is allowed to file name
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a2fe35a84cbcedc929f313e34c45d6f02d81607
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a2fe35a84cbcedc929f313e34c45d6f02d81607
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230905/41f5915a/attachment.html>
More information about the ghc-commits
mailing list