From f352904f11feb685c674871a1f640187c23e3df2 Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Thu, 16 Sep 2021 17:14:01 +0100 Subject: [PATCH 1/3] Generalise `compile` and `actuate` to `MonadIO` --- reactive-banana/CHANGELOG.md | 2 ++ reactive-banana/src/Reactive/Banana/Frameworks.hs | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/reactive-banana/CHANGELOG.md b/reactive-banana/CHANGELOG.md index edb42a30..9411ef03 100644 --- a/reactive-banana/CHANGELOG.md +++ b/reactive-banana/CHANGELOG.md @@ -5,10 +5,12 @@ Changelog for the `reactive-banana** package * Add `merge` and `mergeWith` combinators. [#163][], [#220][] * Make internal SCC pragmas compatible with the GHC 9.0 parser. [#208][] +* Generalise `compile` and `actuate` to `MonadIO`. [#226][] [#163]: https://github.com/HeinrichApfelmus/reactive-banana/pull/163 [#208]: https://github.com/HeinrichApfelmus/reactive-banana/pull/208 [#220]: https://github.com/HeinrichApfelmus/reactive-banana/pull/219 + [#226]: https://github.com/HeinrichApfelmus/reactive-banana/pull/226 **version 1.2.1.0** diff --git a/reactive-banana/src/Reactive/Banana/Frameworks.hs b/reactive-banana/src/Reactive/Banana/Frameworks.hs index e42e1bc8..a1b9bfe3 100644 --- a/reactive-banana/src/Reactive/Banana/Frameworks.hs +++ b/reactive-banana/src/Reactive/Banana/Frameworks.hs @@ -301,8 +301,8 @@ liftIOLater = MIO . Prim.liftIOLater -- | Compile the description of an event network -- into an 'EventNetwork' -- that you can 'actuate', 'pause' and so on. -compile :: MomentIO () -> IO EventNetwork -compile = fmap EN . Prim.compile . unMIO +compile :: MonadIO m => MomentIO () -> m EventNetwork +compile = liftIO . fmap EN . Prim.compile . unMIO {----------------------------------------------------------------------------- Running event networks @@ -314,8 +314,8 @@ newtype EventNetwork = EN { unEN :: Prim.EventNetwork } -- | Actuate an event network. -- The inputs will register their event handlers, so that -- the networks starts to produce outputs in response to input events. -actuate :: EventNetwork -> IO () -actuate = Prim.actuate . unEN +actuate :: MonadIO m => EventNetwork -> m () +actuate = liftIO . Prim.actuate . unEN -- | Pause an event network. -- Immediately stop producing output. From 1b7797473efb93bdc2cfe0e98b6fdef1f5073ceb Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Thu, 16 Sep 2021 19:49:08 +0100 Subject: [PATCH 2/3] Update Frameworks.hs --- reactive-banana/src/Reactive/Banana/Frameworks.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactive-banana/src/Reactive/Banana/Frameworks.hs b/reactive-banana/src/Reactive/Banana/Frameworks.hs index a1b9bfe3..002664a5 100644 --- a/reactive-banana/src/Reactive/Banana/Frameworks.hs +++ b/reactive-banana/src/Reactive/Banana/Frameworks.hs @@ -329,8 +329,8 @@ actuate = liftIO . Prim.actuate . unEN -- i.e. you can use 'pause' as an argument to 'reactimate'. -- The network will /not/ stop immediately though, only after -- the current event has been processed completely. -pause :: EventNetwork -> IO () -pause = Prim.pause . unEN +pause :: MonadIO m => EventNetwork -> m () +pause = liftIO . Prim.pause . unEN {----------------------------------------------------------------------------- Utilities From faa15a5bc82949799c7aeec5055152cebe61c58c Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Thu, 16 Sep 2021 19:49:24 +0100 Subject: [PATCH 3/3] Update CHANGELOG.md --- reactive-banana/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactive-banana/CHANGELOG.md b/reactive-banana/CHANGELOG.md index 9411ef03..ded03de2 100644 --- a/reactive-banana/CHANGELOG.md +++ b/reactive-banana/CHANGELOG.md @@ -5,7 +5,7 @@ Changelog for the `reactive-banana** package * Add `merge` and `mergeWith` combinators. [#163][], [#220][] * Make internal SCC pragmas compatible with the GHC 9.0 parser. [#208][] -* Generalise `compile` and `actuate` to `MonadIO`. [#226][] +* Generalise `compile`, `actuate` and `pause` to `MonadIO`. [#226][] [#163]: https://github.com/HeinrichApfelmus/reactive-banana/pull/163 [#208]: https://github.com/HeinrichApfelmus/reactive-banana/pull/208