polysemy-time-0.1.4.0: Polysemy Effect for Time
Safe HaskellNone
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 :: AddTimeUnit t u1 u2 => 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.

Instances

Instances details
type DefiningModule Time Source # 
Instance details

Defined in Polysemy.Time.Data.Time

type DefiningModule Time = "Polysemy.Time.Data.Time"

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

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

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

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

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

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

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.

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.

Data types

newtype NanoSeconds Source #

Constructors

NanoSeconds 

Fields

Instances

Instances details
Enum NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Eq 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

Num NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Ord 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

Generic NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Associated Types

type Rep NanoSeconds :: Type -> Type #

ToJSON NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

FromJSON NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Additive NanoSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit 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.1.4.0-inplace" 'True) (C1 ('MetaCons "NanoSeconds" 'PrefixI 'True) (S1 ('MetaSel ('Just "unNanoSeconds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype MicroSeconds Source #

Constructors

MicroSeconds 

Instances

Instances details
Enum MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Eq 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

Num MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Ord 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

Generic MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Associated Types

type Rep MicroSeconds :: Type -> Type #

ToJSON MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

FromJSON MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Additive MicroSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit 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.1.4.0-inplace" 'True) (C1 ('MetaCons "MicroSeconds" 'PrefixI 'True) (S1 ('MetaSel ('Just "unMicroSeconds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype MilliSeconds Source #

Constructors

MilliSeconds 

Instances

Instances details
Enum MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Eq 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

Num MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Ord 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

Generic MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Associated Types

type Rep MilliSeconds :: Type -> Type #

ToJSON MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

FromJSON MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Additive MilliSeconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit 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.1.4.0-inplace" 'True) (C1 ('MetaCons "MilliSeconds" 'PrefixI 'True) (S1 ('MetaSel ('Just "unMilliSeconds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype Seconds Source #

Constructors

Seconds 

Fields

Instances

Instances details
Enum 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 #

Integral Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Num Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Ord 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

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 #

ToJSON Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

FromJSON Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Additive Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit 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.1.4.0-inplace" 'True) (C1 ('MetaCons "Seconds" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSeconds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype Minutes Source #

Constructors

Minutes 

Fields

Instances

Instances details
Enum 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 #

Integral Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Num Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Ord 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

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 #

ToJSON Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

FromJSON Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Additive Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit 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.1.4.0-inplace" 'True) (C1 ('MetaCons "Minutes" 'PrefixI 'True) (S1 ('MetaSel ('Just "unMinutes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype Hours Source #

Constructors

Hours 

Fields

Instances

Instances details
Enum Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Eq Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

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

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

Integral Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Num Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

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 #

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 #

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 #

ToJSON Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

FromJSON 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 #

TimeUnit Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

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.1.4.0-inplace" 'True) (C1 ('MetaCons "Hours" 'PrefixI 'True) (S1 ('MetaSel ('Just "unHours") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype Days Source #

Constructors

Days 

Fields

Instances

Instances details
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] #

Eq Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

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

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

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 #

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 #

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 #

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 #

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 #

ToJSON Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

FromJSON 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 #

TimeUnit Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

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.1.4.0-inplace" 'True) (C1 ('MetaCons "Days" 'PrefixI 'True) (S1 ('MetaSel ('Just "unDays") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype Weeks Source #

Constructors

Weeks 

Fields

Instances

Instances details
Enum Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Eq Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

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

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

Integral Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Num Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

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 #

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 #

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 #

ToJSON Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

FromJSON 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 #

TimeUnit Weeks Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

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.1.4.0-inplace" 'True) (C1 ('MetaCons "Weeks" 'PrefixI 'True) (S1 ('MetaSel ('Just "unWeeks") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype Months Source #

Constructors

Months 

Fields

Instances

Instances details
Enum 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 #

Integral Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Num Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Ord 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

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 #

ToJSON Months Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

FromJSON 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.1.4.0-inplace" 'True) (C1 ('MetaCons "Months" 'PrefixI 'True) (S1 ('MetaSel ('Just "unMonths") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype Years Source #

Constructors

Years 

Fields

Instances

Instances details
Enum Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Eq Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Methods

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

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

Integral Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

Num Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

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 #

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 #

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 #

ToJSON Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

FromJSON Years Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

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.1.4.0-inplace" '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 NominalDiffTime Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit DiffTime Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit NanoSeconds 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 Seconds Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit Minutes Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit Hours Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit Days Source # 
Instance details

Defined in Polysemy.Time.Data.TimeUnit

TimeUnit Weeks 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 HasNanoSecond t where Source #

Extract the nanosecond component from a datetime or time.

Instances

Instances details
HasNanoSecond TimeOfDay Source # 
Instance details

Defined in Polysemy.Time.Calendar

HasNanoSecond DiffTime 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 TimeOfDay Source # 
Instance details

Defined in Polysemy.Time.Calendar

HasSecond DiffTime Source # 
Instance details

Defined in Polysemy.Time.Calendar

class HasMinute t where Source #

Extract the minute component from a datetime or time.

Methods

minute :: t -> Minutes Source #

Instances

Instances details
HasMinute TimeOfDay Source # 
Instance details

Defined in Polysemy.Time.Calendar

HasMinute DiffTime Source # 
Instance details

Defined in Polysemy.Time.Calendar

class HasHour t where Source #

Extract the hour component from a datetime or time.

Methods

hour :: t -> Hours Source #

Instances

Instances details
HasHour TimeOfDay Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

hour :: TimeOfDay -> Hours Source #

HasHour DiffTime Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

hour :: DiffTime -> Hours Source #

class HasDay t where Source #

Extract the day component from a date.

Methods

day :: t -> Days Source #

Instances

Instances details
HasDay UTCTime Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

day :: UTCTime -> Days Source #

HasDay Day Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

day :: Day -> Days Source #

class HasMonth t where Source #

Extract the month component from a date.

Methods

month :: t -> Months Source #

Instances

Instances details
HasMonth UTCTime Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

month :: UTCTime -> Months Source #

HasMonth Day Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

month :: Day -> Months Source #

class HasYear t where Source #

Extract the year component from a date.

Methods

year :: t -> Years Source #

Instances

Instances details
HasYear UTCTime Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

year :: UTCTime -> Years Source #

HasYear Day Source # 
Instance details

Defined in Polysemy.Time.Calendar

Methods

year :: Day -> 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.

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.