Skip to content
Snippets Groups Projects
Commit 71a24afa authored by BinderDavid's avatar BinderDavid Committed by Ben Gamari
Browse files

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.

(cherry picked from commit 5a2fe35a)
parent f60efaaf
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment