Skip to content

Commit

Permalink
Merge pull request #297 from ners/never
Browse files Browse the repository at this point in the history
Add Never clock
  • Loading branch information
turion authored Mar 25, 2024
2 parents 56cd545 + 002ade6 commit 7f1fdb9
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rhine/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Revision history for rhine

## 1.2.1

* Added `FRP.Rhine.Clock.Realtime.Never` (clock that never ticks)

## 1.2

* Changed Stdin clock Tag type to Text
Expand Down
1 change: 1 addition & 0 deletions rhine/rhine.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ library
FRP.Rhine.Clock.Realtime.Busy
FRP.Rhine.Clock.Realtime.Event
FRP.Rhine.Clock.Realtime.Millisecond
FRP.Rhine.Clock.Realtime.Never
FRP.Rhine.Clock.Realtime.Stdin
FRP.Rhine.Clock.Select
FRP.Rhine.Clock.Unschedule
Expand Down
1 change: 1 addition & 0 deletions rhine/src/FRP/Rhine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import FRP.Rhine.Clock.Realtime.Audio as X
import FRP.Rhine.Clock.Realtime.Busy as X
import FRP.Rhine.Clock.Realtime.Event as X
import FRP.Rhine.Clock.Realtime.Millisecond as X
import FRP.Rhine.Clock.Realtime.Never as X
import FRP.Rhine.Clock.Realtime.Stdin as X
import FRP.Rhine.Clock.Select as X
import FRP.Rhine.Clock.Unschedule as X
Expand Down
36 changes: 36 additions & 0 deletions rhine/src/FRP/Rhine/Clock/Realtime/Never.hs
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

0 comments on commit 7f1fdb9

Please sign in to comment.