haskore-realtime 0.0.2 → 0.1
raw patch · 9 files changed
+86/−62 lines, 9 filesdep +transformersdep −mtldep ~data-accessordep ~haskorePVP ok
version bump matches the API change (PVP)
Dependencies added: transformers
Dependencies removed: mtl
Dependency ranges changed: data-accessor, haskore
API changes (from Hackage documentation)
+ Haskore.Interface.MIDI.Play: stringCharFromByte :: ByteList -> String
+ Haskore.Interface.MIDI.Play: type ByteList = [Word8]
+ Haskore.RealTime.EventList.TimeBody: append :: T time body -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeBody: collectCoincident :: (C time) => T time body -> T time [body]
+ Haskore.RealTime.EventList.TimeBody: concat :: [T time body] -> T time body
+ Haskore.RealTime.EventList.TimeBody: cons :: time -> body -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeBody: consBody :: body -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeBody: consTime :: time -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeBody: cycle :: T time body -> T time body
+ Haskore.RealTime.EventList.TimeBody: data T time body :: * -> * -> *
+ Haskore.RealTime.EventList.TimeBody: decreaseStart :: (C time) => time -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeBody: delay :: (C time) => time -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeBody: empty :: T time body
+ Haskore.RealTime.EventList.TimeBody: flatten :: (C time) => T time [body] -> T time body
+ Haskore.RealTime.EventList.TimeBody: foldr :: (time -> a -> b) -> (body -> b -> a) -> b -> T time body -> b
+ Haskore.RealTime.EventList.TimeBody: getBodies :: T time body -> [body]
+ Haskore.RealTime.EventList.TimeBody: insert :: (C time, Ord body) => time -> body -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeBody: mapBody :: (body0 -> body1) -> T time body0 -> T time body1
+ Haskore.RealTime.EventList.TimeBody: mapBodyM :: (Monad m) => (body0 -> m body1) -> T time body0 -> m (T time body1)
+ Haskore.RealTime.EventList.TimeBody: mapCoincident :: (C time) => ([a] -> [b]) -> T time a -> T time b
+ Haskore.RealTime.EventList.TimeBody: mapM :: (Monad m) => (time0 -> m time1) -> (body0 -> m body1) -> T time0 body0 -> m (T time1 body1)
+ Haskore.RealTime.EventList.TimeBody: mapM_ :: (Monad m) => (time -> m ()) -> (body -> m ()) -> T time body -> m ()
+ Haskore.RealTime.EventList.TimeBody: mapTime :: (time0 -> time1) -> T time0 body -> T time1 body
+ Haskore.RealTime.EventList.TimeBody: mapTimeTail :: (T time body0 -> T time body1) -> T time body0 -> T time body1
+ Haskore.RealTime.EventList.TimeBody: normalize :: (C time, Ord body) => T time body -> T time body
+ Haskore.RealTime.EventList.TimeBody: null :: T time body -> Bool
+ Haskore.RealTime.EventList.TimeBody: partition :: (Num time) => (body -> Bool) -> T time body -> (T time body, T time body)
+ Haskore.RealTime.EventList.TimeBody: resample :: (C time, RealFrac time, C i, Integral i) => time -> T time body -> T i body
+ Haskore.RealTime.EventList.TimeBody: singleton :: time -> body -> T time body
+ Haskore.RealTime.EventList.TimeBody: slice :: (Eq a, Num time) => (body -> a) -> T time body -> [(a, T time body)]
+ Haskore.RealTime.EventList.TimeBody: snoc :: T time body -> time -> body -> T time body
+ Haskore.RealTime.EventList.TimeBody: toAbsoluteEventList :: (Num time) => time -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeBody: viewBodyL :: T time body -> (body, T time body)
+ Haskore.RealTime.EventList.TimeBody: viewL :: T time body -> Maybe ((time, body), T time body)
+ Haskore.RealTime.EventList.TimeBody: viewTimeL :: T time body -> Maybe (time, T time body)
+ Haskore.RealTime.EventList.TimeTime: append :: (C time) => T time body -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeTime: catMaybes :: (Num time) => T time (Maybe body) -> T time body
+ Haskore.RealTime.EventList.TimeTime: collectCoincident :: (C time) => T time body -> T time [body]
+ Haskore.RealTime.EventList.TimeTime: concat :: (C time) => [T time body] -> T time body
+ Haskore.RealTime.EventList.TimeTime: concatNaive :: (C time) => [T time body] -> T time body
+ Haskore.RealTime.EventList.TimeTime: cons :: time -> body -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeTime: consBody :: body -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeTime: consTime :: time -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeTime: data T time body :: * -> * -> *
+ Haskore.RealTime.EventList.TimeTime: decreaseStart :: (C time) => time -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeTime: delay :: (C time) => time -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeTime: empty :: T time body
+ Haskore.RealTime.EventList.TimeTime: filter :: (Num time) => (body -> Bool) -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeTime: flatten :: (Num time) => T time [body] -> T time body
+ Haskore.RealTime.EventList.TimeTime: foldr :: (time -> a -> b) -> (body -> b -> a) -> a -> T time body -> b
+ Haskore.RealTime.EventList.TimeTime: insert :: (C time, Ord body) => time -> body -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeTime: mapBody :: (body0 -> body1) -> T time body0 -> T time body1
+ Haskore.RealTime.EventList.TimeTime: mapBodyHead :: (body -> body) -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeTime: mapBodyInit :: (T time0 body -> T time1 body) -> T time0 body -> T time1 body
+ Haskore.RealTime.EventList.TimeTime: mapBodyL :: (body -> body, T time0 body -> T time1 body) -> T time0 body -> T time1 body
+ Haskore.RealTime.EventList.TimeTime: mapBodyLast :: (body -> body) -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeTime: mapBodyR :: (T time0 body -> T time1 body, body -> body) -> T time0 body -> T time1 body
+ Haskore.RealTime.EventList.TimeTime: mapBodyTail :: (T time0 body -> T time1 body) -> T time0 body -> T time1 body
+ Haskore.RealTime.EventList.TimeTime: mapCoincident :: (C time) => ([a] -> [b]) -> T time a -> T time b
+ Haskore.RealTime.EventList.TimeTime: mapM :: (Monad m) => (time0 -> m time1) -> (body0 -> m body1) -> T time0 body0 -> m (T time1 body1)
+ Haskore.RealTime.EventList.TimeTime: mapM_ :: (Monad m) => (time -> m ()) -> (body -> m ()) -> T time body -> m ()
+ Haskore.RealTime.EventList.TimeTime: mapTime :: (time0 -> time1) -> T time0 body -> T time1 body
+ Haskore.RealTime.EventList.TimeTime: mapTimeHead :: (time -> time) -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeTime: mapTimeInit :: (T time body0 -> T time body1) -> T time body0 -> T time body1
+ Haskore.RealTime.EventList.TimeTime: mapTimeL :: (time -> time, T time body0 -> T time body1) -> T time body0 -> T time body1
+ Haskore.RealTime.EventList.TimeTime: mapTimeLast :: (time -> time) -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeTime: mapTimeR :: (T time body0 -> T time body1, time -> time) -> T time body0 -> T time body1
+ Haskore.RealTime.EventList.TimeTime: mapTimeTail :: (T time body0 -> T time body1) -> T time body0 -> T time body1
+ Haskore.RealTime.EventList.TimeTime: merge :: (C time, Ord body) => T time body -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeTime: pause :: time -> T time body
+ Haskore.RealTime.EventList.TimeTime: resample :: (C time, RealFrac time, C i, Integral i) => time -> T time body -> T i body
+ Haskore.RealTime.EventList.TimeTime: snoc :: T time body -> body -> time -> T time body
+ Haskore.RealTime.EventList.TimeTime: snocBody :: T time body -> body -> T time body
+ Haskore.RealTime.EventList.TimeTime: snocTime :: T time body -> time -> T time body
+ Haskore.RealTime.EventList.TimeTime: toAbsoluteEventList :: (Num time) => time -> T time body -> T time body
+ Haskore.RealTime.EventList.TimeTime: viewBodyL :: T time body -> Maybe (body, T time body)
+ Haskore.RealTime.EventList.TimeTime: viewBodyR :: T time body -> Maybe (T time body, body)
+ Haskore.RealTime.EventList.TimeTime: viewTimeL :: T time body -> (time, T time body)
+ Haskore.RealTime.EventList.TimeTime: viewTimeR :: T time body -> (T time body, time)
+ Haskore.RealTime.Timer: lift :: (MonadTrans t, Monad m) => T m -> T (t m)
+ Haskore.RealTime.Timer: liftIO :: (MonadIO io) => T IO -> T io
- Haskore.Interface.MIDI.Play: playRaw :: [String] -> ByteString -> IO ()
+ Haskore.Interface.MIDI.Play: playRaw :: [String] -> ByteList -> IO ()
- Haskore.RealTime.EventList.TimeBody: run :: (RealFrac time, MonadIO io) => T -> (body -> io a) -> T time body -> io [a]
+ Haskore.RealTime.EventList.TimeBody: run :: (RealFrac time, Monad m) => T m -> (body -> m a) -> T time body -> m [a]
- Haskore.RealTime.EventList.TimeBody: runCore :: (Fractional time0, RealFrac time1, MonadIO io) => (T time0 body0 -> T time1 body1) -> T -> (time1 -> body1 -> io a) -> T time0 body0 -> io [a]
+ Haskore.RealTime.EventList.TimeBody: runCore :: (Fractional time0, RealFrac time1, Monad m) => (T time0 body0 -> T time1 body1) -> T m -> (time1 -> body1 -> m a) -> T time0 body0 -> m [a]
- Haskore.RealTime.EventList.TimeBody: runRelative :: (C time, RealFrac time, MonadIO io) => T -> (body -> io a) -> T time body -> io [a]
+ Haskore.RealTime.EventList.TimeBody: runRelative :: (C time, RealFrac time, Monad m) => T m -> (body -> m a) -> T time body -> m [a]
- Haskore.RealTime.EventList.TimeBody: runRelativeCore :: (MonadIO io) => T -> (body -> io a) -> T Integer body -> io [a]
+ Haskore.RealTime.EventList.TimeBody: runRelativeCore :: (Monad m) => T m -> (body -> m a) -> T Integer body -> m [a]
- Haskore.RealTime.EventList.TimeBody: runTimeStamp :: (RealFrac time, MonadIO io) => T -> (time -> body -> io a) -> T time body -> io [a]
+ Haskore.RealTime.EventList.TimeBody: runTimeStamp :: (RealFrac time, Monad m) => T m -> (time -> body -> m a) -> T time body -> m [a]
- Haskore.RealTime.EventList.TimeBody: runTimeStampGrouped :: (RealFrac time, MonadIO io) => T -> (time -> [body] -> io a) -> T time body -> io [a]
+ Haskore.RealTime.EventList.TimeBody: runTimeStampGrouped :: (RealFrac time, Monad m) => T m -> (time -> [body] -> m a) -> T time body -> m [a]
- Haskore.RealTime.EventList.TimeTime: run :: (RealFrac time, MonadIO io) => T -> (body -> io a) -> T time body -> io [a]
+ Haskore.RealTime.EventList.TimeTime: run :: (RealFrac time, Monad m) => T m -> (body -> m a) -> T time body -> m [a]
- Haskore.RealTime.EventList.TimeTime: runRelative :: (C time, RealFrac time, MonadIO io) => T -> (body -> io a) -> T time body -> io [a]
+ Haskore.RealTime.EventList.TimeTime: runRelative :: (C time, RealFrac time, Monad m) => T m -> (body -> m a) -> T time body -> m [a]
- Haskore.RealTime.EventList.TimeTime: runTimeStamp :: (RealFrac time, MonadIO io) => T -> (time -> body -> io a) -> T time body -> io [a]
+ Haskore.RealTime.EventList.TimeTime: runTimeStamp :: (RealFrac time, Monad m) => T m -> (time -> body -> m a) -> T time body -> m [a]
- Haskore.RealTime.EventList.TimeTime: runTimeStampGrouped :: (RealFrac time, MonadIO io) => T -> (time -> [body] -> io a) -> T time body -> io [a]
+ Haskore.RealTime.EventList.TimeTime: runTimeStampGrouped :: (RealFrac time, Monad m) => T m -> (time -> [body] -> m a) -> T time body -> m [a]
- Haskore.RealTime.Timer: Cons :: IO ClockTime -> (Int -> IO ()) -> Integer -> T
+ Haskore.RealTime.Timer: Cons :: m ClockTime -> (Int -> m ()) -> Integer -> T m
- Haskore.RealTime.Timer: data T
+ Haskore.RealTime.Timer: data T m
- Haskore.RealTime.Timer: getClockTime :: T -> IO ClockTime
+ Haskore.RealTime.Timer: getClockTime :: T m -> m ClockTime
- Haskore.RealTime.Timer: getTime :: T -> IO Integer
+ Haskore.RealTime.Timer: getTime :: (Monad m) => T m -> m Integer
- Haskore.RealTime.Timer: getTimeSeconds :: (Fractional time) => T -> IO time
+ Haskore.RealTime.Timer: getTimeSeconds :: (Fractional time, Monad m) => T m -> m time
- Haskore.RealTime.Timer: resolution :: T -> Integer
+ Haskore.RealTime.Timer: resolution :: T m -> Integer
- Haskore.RealTime.Timer: wait :: T -> Integer -> IO ()
+ Haskore.RealTime.Timer: wait :: (Monad m) => T m -> Integer -> m ()
- Haskore.RealTime.Timer: waitInt :: T -> Int -> IO ()
+ Haskore.RealTime.Timer: waitInt :: T m -> Int -> m ()
- Haskore.RealTime.Timer: waitUntil :: T -> Integer -> IO ()
+ Haskore.RealTime.Timer: waitUntil :: (Monad m) => T m -> Integer -> m ()
- Haskore.RealTime.Timer: waitUntilSeconds :: (RealFrac time) => T -> time -> IO ()
+ Haskore.RealTime.Timer: waitUntilSeconds :: (RealFrac time, Monad m) => T m -> time -> m ()
- Haskore.RealTime.Timer.Immediate: timer :: T
+ Haskore.RealTime.Timer.Immediate: timer :: (Monad m) => T m
- Haskore.RealTime.Timer.Posix: timer :: T
+ Haskore.RealTime.Timer.Posix: timer :: T IO
- Haskore.RealTime.Timer.Thread: timer :: T
+ Haskore.RealTime.Timer.Thread: timer :: T IO
Files
- haskore-realtime.cabal +15/−7
- src/Haskore/Interface/CSound/Play.hs +3/−3
- src/Haskore/Interface/MIDI/Play.hs +11/−2
- src/Haskore/RealTime/EventList/TimeBody.hs +16/−17
- src/Haskore/RealTime/EventList/TimeTime.hs +13/−14
- src/Haskore/RealTime/Timer.hs +23/−14
- src/Haskore/RealTime/Timer/Immediate.hs +3/−3
- src/Haskore/RealTime/Timer/Posix.hs +1/−1
- src/Haskore/RealTime/Timer/Thread.hs +1/−1
haskore-realtime.cabal view
@@ -1,12 +1,11 @@ Name: haskore-realtime-Version: 0.0.2+Version: 0.1 License: GPL License-File: LICENSE Author: Henning Thielemann <haskell@henning-thielemann.de> Maintainer: Henning Thielemann <haskell@henning-thielemann.de> Homepage: http://www.haskell.org/haskellwiki/Haskore/-Package-URL: http://darcs.haskell.org/haskore-realtime/-Category: Sound+Category: Sound, Music Synopsis: Routines for realtime playback of Haskore songs Description: This package contains support for realtime playback of Haskore songs.@@ -16,23 +15,32 @@ Thus we have removed this part from core Haskore. Stability: Experimental Tested-With: GHC==6.4.1, GHC==6.8.2-Cabal-Version: >=1.2+Cabal-Version: >=1.6 Build-Type: Simple +Source-Repository head+ type: darcs+ location: http://darcs.haskell.org/haskore-realtime/++Source-Repository this+ type: darcs+ location: http://darcs.haskell.org/haskore-realtime/+ tag: 0.1+ Flag splitBase description: Choose the new smaller, split-up base package. Library Build-Depends:- haskore >=0.0.5 && <0.1,+ haskore >=0.1 && <0.2, midi >=0.1.1 && <0.2, bytestring >=0.9 && <1.0, -- dependency on non-negative for Haddock non-negative >=0.0.1 && <0.1, event-list >=0.0.6 && <0.1,- data-accessor >=0.1 && <0.2,+ data-accessor >=0.2 && <0.3, unix >= 2.0 && <3,- mtl >=1.0 && <2+ transformers >=0.0 && <0.2 If flag(splitBase) Build-Depends:
src/Haskore/Interface/CSound/Play.hs view
@@ -12,10 +12,10 @@ import System.IO (IO) import qualified System.IO as IO import qualified System.Posix.Signals as Signals-import System.Cmd(system)-import System.Directory(doesFileExist,removeFile)+import System.Cmd (system, )+import System.Directory(doesFileExist, removeFile, ) -import Haskore.Interface.CSound(Name)+import Haskore.Interface.CSound (Name, ) import qualified Haskore.Interface.CSound.Orchestra as Orchestra import qualified Haskore.Interface.CSound.Score as Score
src/Haskore/Interface/MIDI/Play.hs view
@@ -33,7 +33,6 @@ import System.IO (IO) import qualified System.IO as IO import qualified System.Posix.Signals as Signals-import Haskore.General.IO (ByteString, stringCharFromByte, ) import qualified Haskore.Music.GeneralMIDI as MidiMusic import qualified Haskore.Music.Rhythmic as RhyMusic@@ -47,6 +46,10 @@ import qualified Numeric.NonNegative.Class as NonNeg +import Data.Char (chr, )+import Data.Word (Word8, )++ play :: (Ord instr, Ord drum, NonNeg.C time, RealFrac time, Fractional time, RealFrac dyn) =>@@ -60,7 +63,7 @@ playSimple :: MidiMusic.T -> IO () playSimple = playRaw [] . SaveMidi.toByteList . Render.mixedGeneralMidi -playRaw :: [String] -> ByteString -> IO ()+playRaw :: [String] -> ByteList -> IO () playRaw args stream = do -- Disable sigPIPE. This means that the whole program@@ -77,3 +80,9 @@ (["timidity", "-B", "8,9"] ++ args ++ ["-"]) IO.hPutStr input (stringCharFromByte stream) IO.hClose input+++type ByteList = [Word8]++stringCharFromByte :: ByteList -> String+stringCharFromByte = map (chr . fromIntegral)
src/Haskore/RealTime/EventList/TimeBody.hs view
@@ -29,9 +29,8 @@ import qualified Numeric.NonNegative.Wrapper as NonNegW import qualified Control.Monad as Monad-import Control.Monad.Trans (MonadIO, liftIO) -import Prelude hiding (null, foldr, mapM, mapM_, concat, cycle)+import Prelude hiding (null, foldr, mapM, mapM_, concat, cycle, ) -- * Run actions according to an event list@@ -43,17 +42,17 @@ It is not very useful in practice, but very simple. -} -runRelative :: (NonNeg.C time, RealFrac time, MonadIO io) =>- Timer.T -> (body -> io a) -> T time body -> io [a]+runRelative :: (NonNeg.C time, RealFrac time, Monad m) =>+ Timer.T m -> (body -> m a) -> T time body -> m [a] runRelative timer action = runRelativeCore timer action . resample (fromIntegral $ Timer.resolution timer) -runRelativeCore :: MonadIO io =>- Timer.T -> (body -> io a) -> T NonNegW.Integer body -> io [a]+runRelativeCore :: Monad m =>+ Timer.T m -> (body -> m a) -> T NonNegW.Integer body -> m [a] runRelativeCore timer action = Monad.liftM getBodies .- mapM (liftIO . Timer.wait timer) action+ mapM (Timer.wait timer) action {- | The next set of routines is more precise.@@ -67,8 +66,8 @@ so have to make our ones absolute as well. -} -run :: (RealFrac time, MonadIO io) =>- Timer.T -> (body -> io a) -> T time body -> io [a]+run :: (RealFrac time, Monad m) =>+ Timer.T m -> (body -> m a) -> T time body -> m [a] run timer action = runTimeStamp timer (const action) {- |@@ -76,8 +75,8 @@ but the time passed to the action is not quantized. -} -runTimeStamp :: (RealFrac time, MonadIO io) =>- Timer.T -> (time -> body -> io a) -> T time body -> io [a]+runTimeStamp :: (RealFrac time, Monad m) =>+ Timer.T m -> (time -> body -> m a) -> T time body -> m [a] runTimeStamp = runCore id @@ -88,23 +87,23 @@ That is, collectCoincident will split events which actually belong together. -} -runTimeStampGrouped :: (RealFrac time, MonadIO io) =>- Timer.T -> (time -> [body] -> io a) -> T time body -> io [a]+runTimeStampGrouped :: (RealFrac time, Monad m) =>+ Timer.T m -> (time -> [body] -> m a) -> T time body -> m [a] runTimeStampGrouped = runCore AbsList.collectCoincident -runCore :: (Fractional time0, RealFrac time1, MonadIO io) =>+runCore :: (Fractional time0, RealFrac time1, Monad m) => (AbsList.T time0 body0 -> AbsList.T time1 body1) ->- Timer.T -> (time1 -> body1 -> io a) -> T time0 body0 -> io [a]+ Timer.T m -> (time1 -> body1 -> m a) -> T time0 body0 -> m [a] runCore convertAbs timer action evs = Monad.liftM AbsList.getBodies . AbsList.mapM- (liftIO . Timer.waitUntilSeconds timer)+ (Timer.waitUntilSeconds timer) (uncurry action) . attachTime . convertAbs . flip toAbsoluteEventList evs =<<- liftIO (Timer.getTimeSeconds timer)+ Timer.getTimeSeconds timer {- | We export this function only for use in "Haskore.RealTime.EventList.TimeTime".
src/Haskore/RealTime/EventList/TimeTime.hs view
@@ -37,46 +37,45 @@ -- import qualified Numeric.NonNegative.Wrapper as NonNegW import qualified Control.Monad as Monad-import Control.Monad.Trans (MonadIO, liftIO) import Prelude hiding (concat, filter, foldr, mapM, mapM_) -runRelative :: (NonNeg.C time, RealFrac time, MonadIO io) =>- Timer.T -> (body -> io a) -> T time body -> io [a]+runRelative :: (NonNeg.C time, RealFrac time, Monad m) =>+ Timer.T m -> (body -> m a) -> T time body -> m [a] runRelative timer action = Monad.liftM getBodies .- mapM (liftIO . Timer.wait timer) action .+ mapM (Timer.wait timer) action . resample (fromIntegral $ Timer.resolution timer) -run :: (RealFrac time, MonadIO io) =>- Timer.T -> (body -> io a) -> T time body -> io [a]+run :: (RealFrac time, Monad m) =>+ Timer.T m -> (body -> m a) -> T time body -> m [a] run timer action = runTimeStamp timer (const action) -runTimeStamp :: (RealFrac time, MonadIO io) =>- Timer.T -> (time -> body -> io a) -> T time body -> io [a]+runTimeStamp :: (RealFrac time, Monad m) =>+ Timer.T m -> (time -> body -> m a) -> T time body -> m [a] runTimeStamp = runCore id -runTimeStampGrouped :: (RealFrac time, MonadIO io) =>- Timer.T -> (time -> [body] -> io a) -> T time body -> io [a]+runTimeStampGrouped :: (RealFrac time, Monad m) =>+ Timer.T m -> (time -> [body] -> m a) -> T time body -> m [a] runTimeStampGrouped = runCore AbsList.collectCoincident -runCore :: (Fractional time0, RealFrac time1, MonadIO io) =>+runCore :: (Fractional time0, RealFrac time1, Monad m) => (AbsList.T time0 body0 -> AbsList.T time1 body1) ->- Timer.T -> (time1 -> body1 -> io a) -> T time0 body0 -> io [a]+ Timer.T m -> (time1 -> body1 -> m a) -> T time0 body0 -> m [a] runCore convertAbs timer action evs = Monad.liftM AbsList.getBodies . AbsList.mapM- (liftIO . Timer.waitUntilSeconds timer)+ (Timer.waitUntilSeconds timer) (uncurry action) . attachTime . convertAbs . flip toAbsoluteEventList evs =<<- liftIO (Timer.getTimeSeconds timer)+ Timer.getTimeSeconds timer attachTime :: AbsList.T time body -> AbsList.T time (time, body) attachTime =
src/Haskore/RealTime/Timer.hs view
@@ -1,21 +1,30 @@ module Haskore.RealTime.Timer where -import System.Time(ClockTime(TOD))-import Control.Monad(replicateM_)+import System.Time (ClockTime(TOD))+import Control.Monad (liftM, replicateM_, ) +import qualified Control.Monad.Trans as Trans+ import qualified Numeric.NonNegative.Wrapper as NonNeg -- import Numeric.NonNegative.Class ((-|)) -data T = Cons {- getClockTime :: IO ClockTime,- waitInt :: NonNeg.Int -> IO (),+data T m = Cons {+ getClockTime :: m ClockTime,+ waitInt :: NonNeg.Int -> m (), resolution :: NonNeg.Integer } -getTime :: T -> IO Integer+lift :: (Trans.MonadTrans t, Monad m) => T m -> T (t m)+lift (Cons g w r) = Cons (Trans.lift g) (Trans.lift . w) r++liftIO :: Trans.MonadIO io => T IO -> T io+liftIO (Cons g w r) = Cons (Trans.liftIO g) (Trans.liftIO . w) r+++getTime :: (Monad m) => T m -> m Integer getTime timer =- fmap (clockTimeToWaitTime (resolution timer)) $+ liftM (clockTimeToWaitTime (resolution timer)) $ getClockTime timer clockTimeToWaitTime :: NonNeg.Integer -> ClockTime -> Integer@@ -23,10 +32,10 @@ let res = NonNeg.toNumber res0 in secs * res + div (picos * res) (10^(12::Int)) -getTimeSeconds :: Fractional time =>- T -> IO time+getTimeSeconds :: (Fractional time, Monad m) =>+ T m -> m time getTimeSeconds timer =- fmap clockTimeToSeconds $+ liftM clockTimeToSeconds $ getClockTime timer clockTimeToSeconds :: Fractional time => ClockTime -> time@@ -37,7 +46,7 @@ The range of 32 bit Ints does not suffice for waiting an hour measured in microseconds. -}-wait :: T -> NonNeg.Integer -> IO ()+wait :: (Monad m) => T m -> NonNeg.Integer -> m () wait timer time = let blockSize = maxBound {- Negative delays can occur if multiple events should be scheduled@@ -54,12 +63,12 @@ replicateM_ (fromIntegral reps) (waitInt timer blockSize) >> waitInt timer (fromIntegral remainder) -waitUntil :: T -> Integer -> IO ()+waitUntil :: (Monad m) => T m -> Integer -> m () waitUntil timer time = do tcur <- getTime timer wait timer (NonNeg.fromNumberClip (time - tcur)) -waitUntilSeconds :: (RealFrac time) =>- T -> time -> IO ()+waitUntilSeconds :: (RealFrac time, Monad m) =>+ T m -> time -> m () waitUntilSeconds timer time = waitUntil timer (floor (time * fromIntegral (resolution timer)))
src/Haskore/RealTime/Timer/Immediate.hs view
@@ -10,16 +10,16 @@ import qualified Numeric.NonNegative.Wrapper as NonNeg -timer :: Timer.T+timer :: (Monad m) => Timer.T m timer = Timer.Cons getClockTime wait resolution -getClockTime :: IO ClockTime+getClockTime :: (Monad m) => m ClockTime getClockTime = return $ TOD 0 0 {- | Wait the given number of @(recip resolution)@ seconds. -}-wait :: NonNeg.Int -> IO ()+wait :: (Monad m) => NonNeg.Int -> m () wait _ = return () resolution :: Num a => a
src/Haskore/RealTime/Timer/Posix.hs view
@@ -7,7 +7,7 @@ import qualified Numeric.NonNegative.Wrapper as NonNeg -timer :: Timer.T+timer :: Timer.T IO timer = Timer.Cons getClockTime wait resolution
src/Haskore/RealTime/Timer/Thread.hs view
@@ -9,7 +9,7 @@ import qualified Numeric.NonNegative.Wrapper as NonNeg -timer :: Timer.T+timer :: Timer.T IO timer = Timer.Cons getClockTime wait resolution