shithub: MicroHs

Download patch

ref: de8a34be8d454fc01884b4fb4e066c562b06f4e7
parent: 69e16fa4bab5467b9dc6e864d0e981ce0af4b4cb
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Thu Sep 21 08:36:29 EDT 2023

Add fmap to IO

--- a/lib/Control/Monad/State/Strict.hs
+++ b/lib/Control/Monad/State/Strict.hs
@@ -29,7 +29,7 @@
     (a, ss) -> (f a, ss)
 
 (<$>) :: forall s a b . (a -> b) -> State s a -> State s b
-(<$>) = fmap
+(<$>) = Control.Monad.State.Strict.fmap
 
 modify :: forall s . (s -> s) -> State s ()
 modify f = S $ \ s -> ((), f s)
@@ -71,4 +71,4 @@
 
 when :: forall s . Bool -> State s () -> State s ()
 when True  s = s
-when False _ = Control.Monad.State.Strict.return ()
\ No newline at end of file
+when False _ = Control.Monad.State.Strict.return ()
--- a/lib/System/IO.hs
+++ b/lib/System/IO.hs
@@ -28,6 +28,9 @@
 fail        :: forall a . String -> IO a
 fail s       = error s
 
+fmap        :: forall a b . (a -> b) -> IO a -> IO b
+fmap f ioa   = ioa >>= \ a -> return (f a)
+
 hSerialize   :: forall a . Handle -> a -> IO ()
 hSerialize   = primHSerialize
 hDeserialize :: forall a . Handle -> IO a
--