From b6a53650153ba5f0b6cab3679d582c0788107e9c Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Sun, 6 Dec 2015 03:14:05 -0500 Subject: variable rename & type alias --- midi-dump.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/midi-dump.hs b/midi-dump.hs index 07dfb1c..f332482 100644 --- a/midi-dump.hs +++ b/midi-dump.hs @@ -44,7 +44,7 @@ data LoopState = LoopState { _playNOW :: [Event.Data], _recording :: Recording, _replay :: Recording, - lastTick :: TimeSpec + _lastTick :: TimeSpec } initializeState :: TimeSpec -> LoopState @@ -183,7 +183,11 @@ processCommand "C'" = do -} processCommand str = liftIO $ putStrLn $ "Unknown command: " ++ str -playRecording :: Recording -> RWST LoopEnv () LoopState IO () +type MidiControllerT m = RWST LoopEnv () LoopState m +type MidiController = MidiControllerT IO + +-- playRecording :: Recording -> RWST LoopEnv () LoopState IO () +playRecording :: Recording -> MidiController () playRecording (RecordingInProgress _ _ evts@(_:_)) = mapM_ (uncurry delayNoteEv) (zip (subtract (head delays) <$> delays) events) where (delays, events) = unzip $ fmap Event.body <$> reverse evts @@ -211,7 +215,7 @@ processMidi = do let newEvents = map ((,) now) events liftIO $ printChordLn newKeys - modify $ \s -> s { keysDown = newKeys, _recording = recordEvents (_recording s) newEvents, lastTick = now } + modify $ \s -> s { keysDown = newKeys, _recording = recordEvents (_recording s) newEvents, _lastTick = now } when (Set.null newKeys) $ do @@ -245,7 +249,7 @@ startLineReader = do saveMidi :: forall (m :: * -> *). (MonadIO m, MonadState LoopState m, MonadReader LoopEnv m) => Recording -> m () saveMidi recording = do saver <- asks _saver - now <- gets lastTick + now <- gets _lastTick mapM_ (liftIO . writeChan saver) $ stopRecording recording now startSaver :: forall (m :: * -> *). MonadIO m => Connection -> m (Chan CompleteRecording) -- cgit v1.2.3