polysemy-time-0.6.0.0: Polysemy effects for time
Safe HaskellSafe-Inferred
LanguageHaskell2010

Polysemy.Time

Description

This package provides a Polysemy effect for interacting with the current time and sleeping, as well as some time-related data types and classes.

Synopsis

Documentation

import Data.Time (UTCTime)
import Polysemy (Members, runM)
import Polysemy.Chronos (interpretTimeChronos)
import qualified Polysemy.Time as Time
import Polysemy.Time (MilliSeconds(MilliSeconds), Seconds(Seconds), Time, interpretTimeGhcAt, mkDatetime, year)

prog ::
  Ord t =>
  Member (Time t d) r =>
  Sem r ()
prog = do
  time1 <- Time.now
  Time.sleep (MilliSeconds 10)
  time2 <- Time.now
  print (time1 < time2)
  -- True

testTime :: UTCTime
testTime =
  mkDatetime 1845 12 31 23 59 59

main :: IO ()
main =
  runM do
    interpretTimeChronos prog
    interpretTimeGhcAt testTime do
      Time.sleep (Seconds 1)
      time <- Time.now
      print (year time)
      -- Years { unYear = 1846 }

data Time (time :: Type) (date :: Type) :: Effect where Source #

The Time effect.

Constructors

Now :: Time t d m t

Produce the current time, possibly relative to what was set with SetTime or SetDate

Today :: Time t d m d

Produce the current date, possibly relative to what was set with SetTime or SetDate

Sleep :: TimeUnit u => u -> Time t d m ()

Suspend the current computation for the specified time span.

SetTime :: t -> Time t d m ()

Set the current time, if the interpreter supports it.

Adjust :: TimeUnit u1 => u1 -> Time t d m ()

Adjust the current time relatively, if the interpreter supports it.

SetDate :: d -> Time t d m ()

Set the current date, if the interpreter supports it.

now :: forall t d r. Member (Time t d) r => Sem r t Source #

Produce the current time, possibly relative to what was set with SetTime or SetDate

today :: forall t d r. Member (Time t d) r => Sem r d Source #

Produce the current date, possibly relative to what was set with SetTime or SetDate

sleep :: forall t d u r. TimeUnit u => Member (Time t d) r => u -> Sem r () Source #

Suspend the current computation for the specified time span.

setTime :: forall t d r. Member (Time t d) r => t -> Sem r () Source #

Set the current time, if the interpreter supports it.

adjust :: forall t d u1 u2 r. AddTimeUnit t u1 u2 => Member (Time t d) r => u1 -> Sem r () Source #

Adjust the current time relatively, if the interpreter supports it.

setDate :: forall t d r. Member (Time t d) r => d -> Sem r () Source #

Set the current date, if the interpreter supports it.

type GhcTime = Time UTCTime Day Source #

Convenience alias for Time.

Interpreters

interpretTimeGhc :: Member (Embed IO) r => InterpreterFor GhcTime r Source #

Interpret Time with the types from Time.

interpretTimeGhcAt :: Member (Embed IO) r => UTCTime -> InterpreterFor GhcTime r Source #

Interpret Time with the types from Time, customizing the current time at the start of interpretation.

interpretTimeGhcConstant :: Member (Embed IO) r => UTCTime -> InterpreterFor GhcTime r Source #

Interpret Time with the types from Time, customizing the current time to be constant. Sleeping will only terminate after the time has been advanced by adjust.

interpretTimeGhcConstantNow :: Member (Embed IO) r => InterpreterFor GhcTime r Source #

Interpret Time with the types from Time, customizing the current time to be constantly the time at the start of interpretation. Sleeping will only terminate after the time has been advanced by adjust.

Data types

newtype NanoSeconds Source #

Nanoseconds. This is the base unit for all conversions.

Constructors

NanoSeconds 

Fields

Instances

Instances details
FromJSON NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

ToJSON NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Enum NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Generic NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Associated Types

type Rep NanoSeconds :: Type -> Type #

Num NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Fractional NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Integral NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Real NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Show NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Eq NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Ord NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Additive NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Scaling NanoSeconds Int64 Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep NanoSeconds = D1 ('MetaData "NanoSeconds" "Polysemy.Time.Data.TimeUnit" "polysemy-time-0.6.0.0-GZH2lUvEQqs1TE8ncTXVy6" 'True) (C1 ('MetaCons "NanoSeconds" 'PrefixI 'True) (S1 ('MetaSel ('Just "unNanoSeconds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype MicroSeconds Source #

Microseconds.

Constructors

MicroSeconds 

Instances

Instances details
FromJSON MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

ToJSON MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Enum MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Generic MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Associated Types

type Rep MicroSeconds :: Type -> Type #

Num MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Fractional MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Integral MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Real MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Show MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Eq MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Ord MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Additive MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep MicroSeconds = D1 ('MetaData "MicroSeconds" "Polysemy.Time.Data.TimeUnit" "polysemy-time-0.6.0.0-GZH2lUvEQqs1TE8ncTXVy6" 'True) (C1 ('MetaCons "MicroSeconds" 'PrefixI 'True) (S1 ('MetaSel ('Just "unMicroSeconds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype MilliSeconds Source #

Milliseconds.

Constructors

MilliSeconds 

Instances

Instances details
FromJSON MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

ToJSON MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Enum MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Generic MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Associated Types

type Rep MilliSeconds :: Type -> Type #

Num MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Fractional MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Integral MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Real MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Show MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Eq MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Ord MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Additive MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep MilliSeconds = D1 ('MetaData "MilliSeconds" "Polysemy.Time.Data.TimeUnit" "polysemy-time-0.6.0.0-GZH2lUvEQqs1TE8ncTXVy6" 'True) (C1 ('MetaCons "MilliSeconds" 'PrefixI 'True) (S1 ('MetaSel ('Just "unMilliSeconds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype Seconds Source #

Seconds.

Constructors

Seconds 

Fields

Instances

Instances details
FromJSON Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

ToJSON Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Enum Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Generic Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Associated Types

type Rep Seconds :: Type -> Type #

Methods

from :: Seconds -> Rep Seconds x #

to :: Rep Seconds x -> Seconds #

Num Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Integral Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Real Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Show Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Eq Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

(==) :: Seconds -> Seconds -> Bool #

(/=) :: Seconds -> Seconds -> Bool #

Ord Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Additive Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep Seconds = D1 ('MetaData "Seconds" "Polysemy.Time.Data.TimeUnit" "polysemy-time-0.6.0.0-GZH2lUvEQqs1TE8ncTXVy6" 'True) (C1 ('MetaCons "Seconds" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSeconds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype Minutes Source #

Minutes.

Constructors

Minutes 

Fields

Instances

Instances details
FromJSON Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

ToJSON Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Enum Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Generic Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Associated Types

type Rep Minutes :: Type -> Type #

Methods

from :: Minutes -> Rep Minutes x #

to :: Rep Minutes x -> Minutes #

Num Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Integral Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Real Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Show Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Eq Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

(==) :: Minutes -> Minutes -> Bool #

(/=) :: Minutes -> Minutes -> Bool #

Ord Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Additive Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep Minutes = D1 ('MetaData "Minutes" "Polysemy.Time.Data.TimeUnit" "polysemy-time-0.6.0.0-GZH2lUvEQqs1TE8ncTXVy6" 'True) (C1 ('MetaCons "Minutes" 'PrefixI 'True) (S1 ('MetaSel ('Just "unMinutes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype Hours Source #

Hours.

Constructors

Hours 

Fields

Instances

Instances details
FromJSON Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

ToJSON Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Enum Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Generic Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Associated Types

type Rep Hours :: Type -> Type #

Methods

from :: Hours -> Rep Hours x #

to :: Rep Hours x -> Hours #

Num Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Integral Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Real Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

toRational :: Hours -> Rational #

Show Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

showsPrec :: Int -> Hours -> ShowS #

show :: Hours -> String #

showList :: [Hours] -> ShowS #

Eq Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

(==) :: Hours -> Hours -> Bool #

(/=) :: Hours -> Hours -> Bool #

Ord Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

compare :: Hours -> Hours -> Ordering #

(<) :: Hours -> Hours -> Bool #

(<=) :: Hours -> Hours -> Bool #

(>) :: Hours -> Hours -> Bool #

(>=) :: Hours -> Hours -> Bool #

max :: Hours -> Hours -> Hours #

min :: Hours -> Hours -> Hours #

TimeUnit Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Additive Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

zero :: Hours #

invert :: Hours -> Hours #

plus :: Hours -> Hours -> Hours #

minus :: Hours -> Hours -> Hours #

type Rep Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep Hours = D1 ('MetaData "Hours" "Polysemy.Time.Data.TimeUnit" "polysemy-time-0.6.0.0-GZH2lUvEQqs1TE8ncTXVy6" 'True) (C1 ('MetaCons "Hours" 'PrefixI 'True) (S1 ('MetaSel ('Just "unHours") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype Days Source #

Days.

Constructors

Days 

Fields

Instances

Instances details
FromJSON Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

ToJSON Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Enum Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

succ :: Days -> Days #

pred :: Days -> Days #

toEnum :: Int -> Days #

fromEnum :: Days -> Int #

enumFrom :: Days -> [Days] #

enumFromThen :: Days -> Days -> [Days] #

enumFromTo :: Days -> Days -> [Days] #

enumFromThenTo :: Days -> Days -> Days -> [Days] #

Generic Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Associated Types

type Rep Days :: Type -> Type #

Methods

from :: Days -> Rep Days x #

to :: Rep Days x -> Days #

Num Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

(+) :: Days -> Days -> Days #

(-) :: Days -> Days -> Days #

(*) :: Days -> Days -> Days #

negate :: Days -> Days #

abs :: Days -> Days #

signum :: Days -> Days #

fromInteger :: Integer -> Days #

Integral Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

quot :: Days -> Days -> Days #

rem :: Days -> Days -> Days #

div :: Days -> Days -> Days #

mod :: Days -> Days -> Days #

quotRem :: Days -> Days -> (Days, Days) #

divMod :: Days -> Days -> (Days, Days) #

toInteger :: Days -> Integer #

Real Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

toRational :: Days -> Rational #

Show Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

showsPrec :: Int -> Days -> ShowS #

show :: Days -> String #

showList :: [Days] -> ShowS #

Eq Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

(==) :: Days -> Days -> Bool #

(/=) :: Days -> Days -> Bool #

Ord Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

compare :: Days -> Days -> Ordering #

(<) :: Days -> Days -> Bool #

(<=) :: Days -> Days -> Bool #

(>) :: Days -> Days -> Bool #

(>=) :: Days -> Days -> Bool #

max :: Days -> Days -> Days #

min :: Days -> Days -> Days #

TimeUnit Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Additive Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

zero :: Days #

invert :: Days -> Days #

plus :: Days -> Days -> Days #

minus :: Days -> Days -> Days #

type Rep Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep Days = D1 ('MetaData "Days" "Polysemy.Time.Data.TimeUnit" "polysemy-time-0.6.0.0-GZH2lUvEQqs1TE8ncTXVy6" 'True) (C1 ('MetaCons "Days" 'PrefixI 'True) (S1 ('MetaSel ('Just "unDays") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype Weeks Source #

Weeks.

Constructors

Weeks 

Fields

Instances

Instances details
FromJSON Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

ToJSON Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Enum Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Generic Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Associated Types

type Rep Weeks :: Type -> Type #

Methods

from :: Weeks -> Rep Weeks x #

to :: Rep Weeks x -> Weeks #

Num Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Integral Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Real Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

toRational :: Weeks -> Rational #

Show Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

showsPrec :: Int -> Weeks -> ShowS #

show :: Weeks -> String #

showList :: [Weeks] -> ShowS #

Eq Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

(==) :: Weeks -> Weeks -> Bool #

(/=) :: Weeks -> Weeks -> Bool #

Ord Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

compare :: Weeks -> Weeks -> Ordering #

(<) :: Weeks -> Weeks -> Bool #

(<=) :: Weeks -> Weeks -> Bool #

(>) :: Weeks -> Weeks -> Bool #

(>=) :: Weeks -> Weeks -> Bool #

max :: Weeks -> Weeks -> Weeks #

min :: Weeks -> Weeks -> Weeks #

TimeUnit Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Additive Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

zero :: Weeks #

invert :: Weeks -> Weeks #

plus :: Weeks -> Weeks -> Weeks #

minus :: Weeks -> Weeks -> Weeks #

type Rep Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep Weeks = D1 ('MetaData "Weeks" "Polysemy.Time.Data.TimeUnit" "polysemy-time-0.6.0.0-GZH2lUvEQqs1TE8ncTXVy6" 'True) (C1 ('MetaCons "Weeks" 'PrefixI 'True) (S1 ('MetaSel ('Just "unWeeks") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype Months Source #

Months.

Constructors

Months 

Fields

Instances

Instances details
FromJSON Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

ToJSON Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Enum Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Generic Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Associated Types

type Rep Months :: Type -> Type #

Methods

from :: Months -> Rep Months x #

to :: Rep Months x -> Months #

Num Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Integral Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Real Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Show Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Eq Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

(==) :: Months -> Months -> Bool #

(/=) :: Months -> Months -> Bool #

Ord Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Additive Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep Months = D1 ('MetaData "Months" "Polysemy.Time.Data.TimeUnit" "polysemy-time-0.6.0.0-GZH2lUvEQqs1TE8ncTXVy6" 'True) (C1 ('MetaCons "Months" 'PrefixI 'True) (S1 ('MetaSel ('Just "unMonths") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype Years Source #

Years.

Constructors

Years 

Fields

Instances

Instances details
FromJSON Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

ToJSON Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Enum Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Generic Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Associated Types

type Rep Years :: Type -> Type #

Methods

from :: Years -> Rep Years x #

to :: Rep Years x -> Years #

Num Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Integral Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Real Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

toRational :: Years -> Rational #

Show Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

showsPrec :: Int -> Years -> ShowS #

show :: Years -> String #

showList :: [Years] -> ShowS #

Eq Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

(==) :: Years -> Years -> Bool #

(/=) :: Years -> Years -> Bool #

Ord Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

compare :: Years -> Years -> Ordering #

(<) :: Years -> Years -> Bool #

(<=) :: Years -> Years -> Bool #

(>) :: Years -> Years -> Bool #

(>=) :: Years -> Years -> Bool #

max :: Years -> Years -> Years #

min :: Years -> Years -> Years #

Additive Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

zero :: Years #

invert :: Years -> Years #

plus :: Years -> Years -> Years #

minus :: Years -> Years -> Years #

type Rep Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

type Rep Years = D1 ('MetaData "Years" "Polysemy.Time.Data.TimeUnit" "polysemy-time-0.6.0.0-GZH2lUvEQqs1TE8ncTXVy6" 'True) (C1 ('MetaCons "Years" 'PrefixI 'True) (S1 ('MetaSel ('Just "unYear") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

class TimeUnit u Source #

Types that represent an amount of time that can be converted to each other. The methods are internal, the API function is convert.

Minimal complete definition

nanos

Instances

Instances details
TimeUnit Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit DiffTime Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit NominalDiffTime Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

convert :: TimeUnit a => TimeUnit b => a -> b Source #

Convert between different time spans.

>>> convert (picosecondsToDiffTime 50000000) :: MicroSeconds
MicroSeconds {unMicroSeconds = 50}
>>> convert (MilliSeconds 5) :: MicroSeconds
MicroSeconds 5000

class Calendar dt where Source #

Construct datetimes, dates or times from integers.

Associated Types

type CalendarDate dt :: Type Source #

type CalendarTime dt :: Type Source #

Instances

Instances details
Calendar UTCTime Source # 
Instance details

Defined in Polysemy.Time.Calendar

class HasDay t where Source #

Extract the day component from a date.

Methods

day :: t -> Days Source #

Instances

Instances details
HasDay Day Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

day :: Day -> Days Source #

HasDay UTCTime Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

day :: UTCTime -> Days Source #

class HasHour t where Source #

Extract the hour component from a datetime or time.

Methods

hour :: t -> Hours Source #

Instances

Instances details
HasHour DiffTime Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

hour :: DiffTime -> Hours Source #

HasHour TimeOfDay Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

hour :: TimeOfDay -> Hours Source #

class HasMinute t where Source #

Extract the minute component from a datetime or time.

Methods

minute :: t -> Minutes Source #

Instances

Instances details
HasMinute DiffTime Source # 
Instance details

Defined in Polysemy.Time.Calendar

HasMinute TimeOfDay Source # 
Instance details

Defined in Polysemy.Time.Calendar

class HasMonth t where Source #

Extract the month component from a date.

Methods

month :: t -> Months Source #

Instances

Instances details
HasMonth Day Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

month :: Day -> Months Source #

HasMonth UTCTime Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

month :: UTCTime -> Months Source #

class HasNanoSecond t where Source #

Extract the nanosecond component from a datetime or time.

Instances

Instances details
HasNanoSecond DiffTime Source # 
Instance details

Defined in Polysemy.Time.Calendar

HasNanoSecond TimeOfDay Source # 
Instance details

Defined in Polysemy.Time.Calendar

class HasSecond t where Source #

Extract the second component from a datetime or time.

Methods

second :: t -> Seconds Source #

Instances

Instances details
HasSecond DiffTime Source # 
Instance details

Defined in Polysemy.Time.Calendar

HasSecond TimeOfDay Source # 
Instance details

Defined in Polysemy.Time.Calendar

class HasYear t where Source #

Extract the year component from a date.

Methods

year :: t -> Years Source #

Instances

Instances details
HasYear Day Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

year :: Day -> Years Source #

HasYear UTCTime Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

year :: UTCTime -> Years Source #

Combinators

measure :: forall dt t d u r a. TimeUnit u => Torsor dt u => Instant t dt => Member (Time t d) r => Sem r a -> Sem r (u, a) Source #

Run the action ma and measure the time it takes.

The type of the difference depends on the functional dependencies of the classes Instant and Torsor, where the input to the former is taken from the type t of Time which is instantiated by an interpreter.

while :: forall t d u r. Member (Time t d) r => TimeUnit u => u -> Sem r Bool -> Sem r () Source #

Repeatedly run the action, sleeping for interval between executions. Stops when action returns False.

untilJust :: forall t d u r a. Member (Time t d) r => TimeUnit u => u -> Sem r (Maybe a) -> Sem r a Source #

Repeatedly run the action, sleeping for interval between executions. Stops when action returns Just a, returning the contained a.

loop :: forall t d u a r. Member (Time t d) r => TimeUnit u => u -> a -> (a -> Sem r a) -> Sem r () Source #

Repeatedly run the action, sleeping for interval between executions. The result of action is passed back to it for the next run, starting with initial.

loop_ :: forall t d u r. Member (Time t d) r => TimeUnit u => u -> Sem r () -> Sem r () Source #

Repeatedly run the action, sleeping for interval between executions.

diff :: forall dt u i1 i2 diff. TimeUnit diff => TimeUnit u => Torsor dt diff => Instant i1 dt => Instant i2 dt => i1 -> i2 -> u Source #

Subtract two arbitrary values that can be converted to an Instant.

since :: forall u t d dt diff r. TimeUnit diff => TimeUnit u => Instant t dt => Torsor dt diff => Member (Time t d) r => t -> Sem r u Source #

Calculate the duration between the given Instant and the current time.