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]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

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 (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
Distributions NixOS:0.4.0.0
Downloads 1447 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-0.4.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