polysemy-chronos: A Polysemy effect for Chronos

[ library, time ] [ Propose Tags ]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.2.0, 0.1.2.1, 0.1.2.2, 0.1.2.3, 0.1.2.4, 0.1.3.0, 0.1.3.1, 0.1.3.2, 0.1.4.0, 0.2.0.0, 0.2.0.1, 0.2.0.2, 0.2.0.3, 0.3.0.0, 0.4.0.0, 0.5.0.0, 0.5.1.0, 0.6.0.0, 0.6.0.1, 0.6.0.2, 0.7.0.0 (info)
Change log changelog.md
Dependencies base (>=4.17.2.1 && <4.20), chronos (>=1.1.5 && <1.2), incipit-core (>=0.4.1.0 && <0.7), polysemy-time (>=0.7.0.0 && <0.8) [details]
License BSD-2-Clause-Patent
Copyright 2023 Torsten Schmits
Author Torsten Schmits
Maintainer hackage@tryp.io
Category Time
Home page https://github.com/tek/polysemy-time#readme
Bug tracker https://github.com/tek/polysemy-time/issues
Source repo head: git clone https://github.com/tek/polysemy-time
Uploaded by tek at 2024-05-26T15:44:58Z
Distributions
Reverse Dependencies 9 direct, 11 indirect [details]
Downloads 2437 total (110 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-0.7.0.0

[back to package description]

About

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

Example

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