rhine-1.4: Functional Reactive Programming with type-level clocks
Safe HaskellSafe-Inferred
LanguageHaskell2010

FRP.Rhine.Clock.Except

Synopsis

ExceptClock

newtype ExceptClock cl e Source #

Handle IO exceptions purely in ExceptT.

The clock cl may throw Exceptions of type e while running. These exceptions are automatically caught, and raised as an error in ExceptT (or more generally in MonadError, which implies the presence of ExceptT in the monad transformer stack)

It can then be caught and handled with CatchClock.

Constructors

ExceptClock 

Fields

Instances

Instances details
(Exception e, Clock IO cl, MonadIO eio, MonadError e eio) => Clock eio (ExceptClock cl e) Source # 
Instance details

Defined in FRP.Rhine.Clock.Except

Associated Types

type Time (ExceptClock cl e) Source #

type Tag (ExceptClock cl e) Source #

Methods

initClock :: ExceptClock cl e -> RunningClockInit eio (Time (ExceptClock cl e)) (Tag (ExceptClock cl e)) Source #

GetClockProxy (ExceptClock cl e) Source # 
Instance details

Defined in FRP.Rhine.Clock.Except

type Tag (ExceptClock cl e) Source # 
Instance details

Defined in FRP.Rhine.Clock.Except

type Tag (ExceptClock cl e) = Tag cl
type Time (ExceptClock cl e) Source # 
Instance details

Defined in FRP.Rhine.Clock.Except

type Time (ExceptClock cl e) = Time cl

CatchClock

data CatchClock cl1 e cl2 Source #

Catch an exception in one clock and proceed with another.

When cl1 throws an exception e (in ExceptT e) while running, this exception is caught, and a clock cl2 is started from the exception value.

For this to be possible, cl1 must run in the monad ExceptT e m, while cl2 must run in m. To give cl2 the ability to throw another exception, you need to add a further ExceptT layer to the stack in m.

Constructors

CatchClock cl1 (e -> cl2) 

Instances

Instances details
(Time cl1 ~ Time cl2, Clock (ExceptT e m) cl1, Clock m cl2, Monad m) => Clock m (CatchClock cl1 e cl2) Source # 
Instance details

Defined in FRP.Rhine.Clock.Except

Associated Types

type Time (CatchClock cl1 e cl2) Source #

type Tag (CatchClock cl1 e cl2) Source #

Methods

initClock :: CatchClock cl1 e cl2 -> RunningClockInit m (Time (CatchClock cl1 e cl2)) (Tag (CatchClock cl1 e cl2)) Source #

GetClockProxy (CatchClock cl1 e cl2) Source # 
Instance details

Defined in FRP.Rhine.Clock.Except

type Tag (CatchClock cl1 e cl2) Source # 
Instance details

Defined in FRP.Rhine.Clock.Except

type Tag (CatchClock cl1 e cl2) = Either (Tag cl2) (Tag cl1)
type Time (CatchClock cl1 e cl2) Source # 
Instance details

Defined in FRP.Rhine.Clock.Except

type Time (CatchClock cl1 e cl2) = Time cl1

catchClSF Source #

Arguments

:: (Time cl1 ~ Time cl2, Monad m) 
=> ClSF m cl1 a b

Executed until cl1 throws an exception

-> ClSF m cl2 a b

Executed after cl1 threw an exception, when cl2 is started

-> ClSF m (CatchClock cl1 e cl2) a b 

Combine two ClSFs under two different clocks.

SafeClock

type SafeClock m = HoistClock (ExceptT Void m) m Source #

A clock that throws no exceptions.

safeClock :: Functor m => cl -> SafeClock m cl Source #

Remove ExceptT from the monad of a clock, proving that no exception can be thrown.

Single clock

data Single m time tag e Source #

A clock that emits a single tick, and then throws an exception.

The tag, time measurement and exception have to be supplied as clock value.

Constructors

Single 

Fields

  • singleTag :: tag

    The tag that will be emitted on the tick.

  • getTime :: m time

    A method to measure the current time.

  • exception :: e

    The exception to throw after the single tick.

Instances

Instances details
(TimeDomain time, MonadError e m) => Clock m (Single m time tag e) Source # 
Instance details

Defined in FRP.Rhine.Clock.Except

Associated Types

type Time (Single m time tag e) Source #

type Tag (Single m time tag e) Source #

Methods

initClock :: Single m time tag e -> RunningClockInit m (Time (Single m time tag e)) (Tag (Single m time tag e)) Source #

type Tag (Single m time tag e) Source # 
Instance details

Defined in FRP.Rhine.Clock.Except

type Tag (Single m time tag e) = tag
type Time (Single m time tag e) Source # 
Instance details

Defined in FRP.Rhine.Clock.Except

type Time (Single m time tag e) = time

DelayException

type DelayException m time cl e1 e2 = CatchClock cl e1 (Single m time e1 e2) Source #

Catch an exception in clock cl and throw it after one time step.

This is particularly useful if you want to give your signal network a chance to save its current state in some way.

delayException Source #

Arguments

:: (Monad m, Clock (ExceptT e1 m) cl, MonadError e2 m) 
=> cl

The clock that will throw an exception e

-> (e1 -> e2)

How to transform the exception into the new exception that will be thrown later

-> m (Time cl)

How to measure the current time

-> DelayException m (Time cl) cl e1 e2 

Construct a DelayException clock.

delayException' :: (Monad m, MonadError e m, Clock (ExceptT e m) cl) => cl -> m (Time cl) -> DelayException m (Time cl) cl e e Source #

Like delayException, but the exception thrown by cl and by the DelayException clock are the same.

type DelayMonadIOException m cl e1 e2 = DelayException m UTCTime (ExceptClock cl e1) e1 e2 Source #

Catch an IO Exception, and throw it after one time step.

delayMonadIOException :: (Exception e1, MonadIO m, MonadError e2 m, Clock IO cl, Time cl ~ UTCTime) => cl -> (e1 -> e2) -> DelayMonadIOException m cl e1 e2 Source #

Build a DelayMonadIOException. The time will be measured using the system time.

delayMonadIOError' :: (MonadError IOError m, MonadIO m, Clock IO cl, Time cl ~ UTCTime) => cl -> DelayMonadIOError m cl IOError Source #

Like delayMonadIOError, but throw the error without transforming it.

type DelayIOException cl e1 e2 = DelayException (ExceptT e2 IO) UTCTime (ExceptClock cl e1) e1 e2 Source #

DelayMonadIOException specialised to the monad ExceptT e2 IO.

This is sometimes helpful when the type checker complains about an ambigous monad type variable.

delayIOException :: (Exception e1, Clock IO cl, Time cl ~ UTCTime) => cl -> (e1 -> e2) -> DelayIOException cl e1 e2 Source #

delayMonadIOException specialised to the monad ExceptT e2 IO.

delayIOException' :: (Exception e, Clock IO cl, Time cl ~ UTCTime) => cl -> DelayIOException cl e e Source #

delayIOException', but throw the error without transforming it.

delayIOError :: (Time cl ~ UTCTime, Clock IO cl) => cl -> (IOError -> e) -> DelayIOError cl e Source #

delayIOException specialised to IOError.

delayIOError' :: (Time cl ~ UTCTime, Clock IO cl) => cl -> DelayIOError cl IOError Source #

delayIOError, but throw the error without transforming it.