{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
module FRP.Rhine.Clock.Realtime.Stdin where
import Data.Time.Clock
import Data.Semigroup
import Control.Monad.IO.Class
import FRP.Rhine.Clock
import Data.Semigroup
data StdinClock = StdinClock
instance MonadIO m => Clock m StdinClock where
type Time StdinClock = UTCTime
type Tag StdinClock = String
initClock _ = do
initialTime <- liftIO getCurrentTime
return
( arrM_ $ liftIO $ do
line <- getLine
time <- getCurrentTime
return (time, line)
, initialTime
)
instance Semigroup StdinClock where
_ <> _ = StdinClock