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

Copyright(c) Antony Courtney and Henrik Nilsson Yale University 2003
LicenseBSD-style (see the LICENSE file in the distribution)
Maintainerivan.perez@keera.co.uk
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell98

FRP.Yampa.Task

Description

Task abstraction on top of signal transformers.

Synopsis

Documentation

data Task a b c Source #

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

Instances
Monad (Task a b) Source # 
Instance details

Defined in FRP.Yampa.Task

Methods

(>>=) :: Task a b a0 -> (a0 -> Task a b b0) -> Task a b b0 #

(>>) :: Task a b a0 -> Task a b b0 -> Task a b b0 #

return :: a0 -> Task a b a0 #

fail :: String -> Task a b a0 #

Functor (Task a b) Source # 
Instance details

Defined in FRP.Yampa.Task

Methods

fmap :: (a0 -> b0) -> Task a b a0 -> Task a b b0 #

(<$) :: a0 -> Task a b b0 -> Task a b a0 #

Applicative (Task a b) Source # 
Instance details

Defined in FRP.Yampa.Task

Methods

pure :: a0 -> Task a b a0 #

(<*>) :: Task a b (a0 -> b0) -> Task a b a0 -> Task a b b0 #

liftA2 :: (a0 -> b0 -> c) -> Task a b a0 -> Task a b b0 -> Task a b c #

(*>) :: Task a b a0 -> Task a b b0 -> Task a b b0 #

(<*) :: Task a b a0 -> Task a b b0 -> Task a b a0 #

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

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) Source #

Runs a task.

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.

runTask_ :: Task a b c -> SF a b Source #

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) Source #

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

Non-terminating task with constant output b.

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

Sleeps for t seconds with constant output b.

snapT :: Task a b a Source #

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

Impose a time out on a task.

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

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