polysemy-chronos: Polysemy-time Interpreters for Chronos

[ library, time ] [ Propose Tags ]

Please see the readme on Github at https://github.com/tek/polysemy-time

[Skip to Readme]


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,,,,,,,,,,,,,,,,,,, (info)
Change log changelog.md
Dependencies base (>=4 && <5), chronos (>=1.1.1 && <1.2), incipit-core (>=0.2), polysemy-time [details]
License BSD-2-Clause-Patent
Copyright 2021 Torsten Schmits
Author Torsten Schmits
Maintainer tek@tryp.io
Category Time
Uploaded by tek at 2022-03-10T20:02:03Z
Reverse Dependencies 9 direct, 11 indirect [details]
Downloads 1930 total (18 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for polysemy-chronos-

[back to package description]


This Haskell library provides interpreters for the Time effect from polysemy-time.


import Polysemy (Members, runM)
import Polysemy.Chronos (ChronosTime, interpretTimeChronosConstantAt, interpretTimeChronos)
import qualified Polysemy.Time as Time
import Polysemy.Time (MilliSeconds(MilliSeconds), mkDatetime)

startTime :: Chronos.Time
startTime =
  Chronos.datetimeToTime (Time.mkDatetime 2020 01 01 0 0 0)

prog ::
  Ord t =>
  Members [ChronosTime, Embed IO] r =>
  Sem r Bool
prog = do
  Time.sleep (MilliSeconds 1)
  time <- Time.now
  pure (time == startTime)

main :: IO ()
main =
  runM do
    print =<< interpretTimeChronos prog -- False
    print =<< interpretTimeChronosConstantAt prog -- True