Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions io-classes/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### Breaking changes

+* Changed `Time` show instance, which now is designed for pasting
+ counterexamples from terminal to an editor.

### Non-breaking changes

* Improved performance of `tryReadTBQueueDefault`.
Expand Down
8 changes: 6 additions & 2 deletions io-classes/si-timers/src/Control/Monad/Class/MonadTime/SI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,27 @@ import Control.Monad.Class.MonadTime qualified as MonadTime

import NoThunks.Class (NoThunks (..))

import Data.Fixed (Pico, showFixed)
import Data.Time.Clock (DiffTime)
import Data.Time.Clock qualified as Time
import Data.Word (Word64)
import GHC.Generics (Generic (..))


-- | A point in time in a monotonic clock.
-- | A point in time in a monotonic clock counted in seconds.
--
-- The epoch for this clock is arbitrary and does not correspond to any wall
-- clock or calendar, and is /not guaranteed/ to be the same epoch across
-- program runs. It is represented as the 'DiffTime' from this arbitrary epoch.
--
newtype Time = Time DiffTime
deriving stock (Eq, Ord, Show, Generic)
deriving stock (Eq, Ord, Generic)
deriving newtype NFData
deriving anyclass NoThunks

instance Show Time where
show (Time t) = "Time " ++ showFixed True (realToFrac t :: Pico)

-- | The time duration between two points in time (positive or negative).
diffTime :: Time -> Time -> DiffTime
diffTime (Time t) (Time t') = t - t'
Expand Down
Loading