packages feed

rhine-terminal 1.7 → 1.8

raw patch · 2 files changed

+27/−28 lines, 2 filesdep +automatondep −monad-scheduledep ~basedep ~rhinePVP ok

version bump matches the API change (PVP)

Dependencies added: automaton

Dependencies removed: monad-schedule

Dependency ranges changed: base, rhine

API changes (from Hackage documentation)

- FRP.Rhine.Terminal: instance (GHC.Base.Monad m, Control.Monad.Schedule.Class.MonadSchedule m) => Control.Monad.Schedule.Class.MonadSchedule (System.Terminal.TerminalT.TerminalT t m)
+ FRP.Rhine.Terminal: instance (GHC.Base.Monad m, Data.Automaton.Schedule.MonadSchedule m) => Data.Automaton.Schedule.MonadSchedule (System.Terminal.TerminalT.TerminalT t m)

Files

rhine-terminal.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: rhine-terminal-version: 1.7+version: 1.8 synopsis: Terminal backend for Rhine description: This package provides an example of a `terminal` based program using rhine. license: BSD-3-Clause@@ -24,10 +24,10 @@  common opts   build-depends:-    base >=4.16 && <4.22,+    automaton ^>=1.8,+    base >=4.18 && <4.22,     exceptions >=0.10.4,-    monad-schedule >=1.6,-    rhine ^>=1.7,+    rhine ^>=1.8,     terminal >=0.2.0.0,     text >=1.2,     time >=1.9.3,
src/FRP/Rhine/Terminal.hs view
@@ -11,31 +11,30 @@   flowTerminal,   RunTerminalClock,   runTerminalClock,-) where+)+where  -- base -import Unsafe.Coerce (unsafeCoerce)-import Prelude hiding (putChar)- -- exceptions import Control.Monad.Catch (MonadMask)  -- time-import Data.Time.Clock (getCurrentTime)  -- terminal-import System.Terminal (Event, Interrupt, MonadInput, TerminalT, awaitEvent, runTerminalT)-import System.Terminal.Internal (Terminal)  -- transformers import Control.Monad.Trans.Reader --- monad-schedule-import Control.Monad.Schedule.Class- -- rhine++import Data.Automaton.Schedule (MonadSchedule (..))+import Data.Time.Clock (getCurrentTime) import FRP.Rhine+import System.Terminal (Event, Interrupt, MonadInput, TerminalT, awaitEvent, runTerminalT)+import System.Terminal.Internal (Terminal)+import Unsafe.Coerce (unsafeCoerce)+import Prelude hiding (putChar)  -- | A clock that ticks whenever events or interrupts on the terminal arrive. data TerminalEventClock = TerminalEventClock@@ -46,11 +45,11 @@    initClock TerminalEventClock = do     initialTime <- liftIO getCurrentTime-    return+    pure       ( constM $ do           event <- awaitEvent           time <- liftIO getCurrentTime-          return (time, event)+          pure (time, event)       , initialTime       )   {-# INLINE initClock #-}@@ -61,17 +60,17 @@   t <> _ = t  {- | A function wrapping `flow` to use at the top level- in order to run a `Rhine (TerminalT t m) cl ()`+in order to run a `Rhine (TerminalT t m) cl ()` - Example:+Example: - @- mainRhine :: MonadIO m => Rhine (TerminalT LocalTerminal m) TerminalEventClock () ()- mainRhine = tagS >-> arrMCl (liftIO . print) @@ TerminalEventClock+@+mainRhine :: MonadIO m => Rhine (TerminalT LocalTerminal m) TerminalEventClock () ()+mainRhine = tagS >-> arrMCl (liftIO . print) @@ TerminalEventClock - main :: IO ()- main = withTerminal $ \term -> `flowTerminal` term mainRhine- @+main :: IO ()+main = withTerminal $ \term -> `flowTerminal` term mainRhine+@ -} flowTerminal ::   ( MonadIO m@@ -88,9 +87,9 @@ flowTerminal term clsf = flip runTerminalT term $ flow clsf  {- | To escape the 'TerminalT' transformer,-  you can apply this operator to your clock type,-  where @cl@ is a clock in 'TerminalT'.-  The resulting clock is then in @m@.+ you can apply this operator to your clock type,+ where @cl@ is a clock in 'TerminalT'.+ The resulting clock is then in @m@. -} type RunTerminalClock m t cl = HoistClock (TerminalT t m) m cl @@ -115,4 +114,4 @@ unTerminalT = unsafeCoerce  instance (Monad m, MonadSchedule m) => MonadSchedule (TerminalT t m) where-  schedule = terminalT . fmap (fmap (fmap terminalT)) . schedule . fmap unTerminalT+  schedule = hoistS terminalT . schedule . fmap (hoistS unTerminalT)