-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #297 from ners/never
Add Never clock
- Loading branch information
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
|
||
-- | A clock that never ticks. | ||
module FRP.Rhine.Clock.Realtime.Never where | ||
|
||
-- base | ||
import Control.Concurrent (threadDelay) | ||
import Control.Monad (forever) | ||
import Data.Void (Void) | ||
|
||
-- time | ||
import Data.Time.Clock | ||
|
||
-- rhine | ||
import FRP.Rhine.Clock | ||
import FRP.Rhine.Clock.Proxy | ||
|
||
-- transformers | ||
import Control.Monad.IO.Class | ||
|
||
-- | A clock that never ticks. | ||
data Never = Never | ||
|
||
instance (MonadIO m) => Clock m Never where | ||
type Time Never = UTCTime | ||
type Tag Never = Void | ||
|
||
initClock _ = do | ||
initialTime <- liftIO getCurrentTime | ||
return | ||
( constM (liftIO . forever . threadDelay $ 10 ^ 9) | ||
, initialTime | ||
) | ||
|
||
instance GetClockProxy Never |