packages feed

pipes-misc 0.2.1.1 → 0.2.2.0

raw patch · 2 files changed

+1/−42 lines, 2 files

Files

pipes-misc.cabal view
@@ -1,5 +1,5 @@ name:                pipes-misc-version:             0.2.1.1+version:             0.2.2.0 synopsis:            Miscellaneous utilities for pipes, required by glazier-tutorial description:         Please see README.md homepage:            https://github.com/louispan/pipes-misc#readme@@ -16,7 +16,6 @@ library   hs-source-dirs:      src   exposed-modules:     Pipes.Misc-                       Pipes.Stopwatch   build-depends:       base >= 4.7 && < 5                      , clock >= 0.7 && < 1                      , lens >= 4 && < 5
− src/Pipes/Stopwatch.hs
@@ -1,40 +0,0 @@-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE RankNTypes #-}-{-# LANGUAGE TemplateHaskell #-}--module Pipes.Stopwatch where--import Control.Lens-import Control.Monad.Trans-import qualified Pipes as P-import qualified System.Clock as C---- | Record of epoch time and elapsed time-data Stopwatch = Stopwatch-    { stopwatchEpochTime :: {-# UNPACK #-}!C.TimeSpec -- | time since application epoch-    , stopwatchLapTime :: {-# UNPACK #-}!C.TimeSpec -- | time since last frame-    } deriving (Eq, Show)--makeFields ''Stopwatch---- | Create a stopwatch pipe using first yielded time as the application epoch--- and previous laptime-stopwatch :: MonadIO io => P.Pipe () Stopwatch io ()-stopwatch = do-    P.await-    t <- liftIO $ C.getTime C.ThreadCPUTime-    P.yield $ Stopwatch startTime startTime-    stopwatch' t t-  where-    startTime = C.TimeSpec 0 0---- | Create a stopwatch Pipe using a given application epoch time and previous laptime-stopwatch' :: MonadIO io => C.TimeSpec -> C.TimeSpec -> P.Pipe () Stopwatch io ()-stopwatch' epoch prev = go prev-  where-    go prev' = do-        () <- P.await-        t <- liftIO $ C.getTime C.ThreadCPUTime-        P.yield $ Stopwatch (C.diffTimeSpec t epoch) (C.diffTimeSpec t prev')-        go t