Skip to contents

Timer Monad

Timer Monad

Details

Creates a Timer monad instance which can be used with the flatMap operator %>>=%. See the Monads in R vignette for more details.

This container, when flatMapped, records the evaluation time of the expressions used at each step, and these can be recovered from the object, along with the expressions themselves.

Usage

x <- Timer$new(value)

x$bind()

x$value
x$times

Details

$new(value) creates a new instance wrapping value.

$bind() is used within %>>=% and re-wraps as a new Timer.

$value extracts the value field. value(x) is a wrapper for this. $times extracts the times field. times(x) is a wrapper for this.

See also

Public fields

value

value contained in the instance

times

evaluation times

Methods


Method new()

create a new Timer instance

Usage

Timer$new(value)

Arguments

value

value to be contained

Returns

a new Timer instance


Method bind()

bind when using flatMap (%>>=%)

Usage

Timer$bind(f, expr)

Arguments

f

function to apply

expr

expression of the function


Method clone()

The objects of this class are cloneable with this method.

Usage

Timer$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.