Yampa-0.13.1: Elegant Functional Reactive Programming Language for Hybrid Systems

Copyright (c) Antony Courtney and Henrik Nilsson Yale University 2003 BSD-style (see the LICENSE file in the distribution) ivan.perez@keera.co.uk provisional non-portable (GHC extensions) None Haskell98

Description

Task abstraction on top of signal transformers.

Synopsis

# Documentation

data Task a b c #

A task is a partially SF that may terminate with a result.

Instances

mkTask :: SF a (b, Event c) -> Task a b c #

Creates a Task from an SF that returns, as a second output, an Event when the SF terminates. See switch.

runTask :: Task a b c -> SF a (Either b c) #

The output from the resulting signal transformer is tagged with Left while the underlying task is running. Once the task has terminated, the output goes constant with the value Right x, where x is the value of the terminating event.

Runs a task that never terminates.

The output becomes undefined once the underlying task has terminated.

Convenience function for tasks which are known not to terminate.

taskToSF :: Task a b c -> SF a (b, Event c) #

Creates an SF that represents an SF and produces an event when the task terminates, and otherwise produces just an output.

constT :: b -> Task a b c #

Non-terminating task with constant output b.

sleepT :: Time -> b -> Task a b () #

Sleeps for t seconds with constant output b.

snapT :: Task a b a #

Takes a "snapshot" of the input and terminates immediately with the input value as the result.

No time passes; therefore, the following must hold:

snapT >> snapT = snapT

timeOut :: Task a b c -> Time -> Task a b (Maybe c) infixl 0 #

Impose a time out on a task.

abortWhen :: Task a b c -> SF a (Event d) -> Task a b (Either c d) infixl 0 #

Run a "guarding" event source (SF a (Event b)) in parallel with a (possibly non-terminating) task.

The task will be aborted at the first occurrence of the event source (if it has not terminated itself before that).

Useful for separating sequencing and termination concerns. E.g. we can do something "useful", but in parallel watch for a (exceptional) condition which should terminate that activity, without having to check for that condition explicitly during each and every phase of the activity.

Example: tsk abortWhen lbp