forsyde-shallow-3.4.0.0: ForSyDe's Haskell-embedded Domain Specific Language.

Copyright(c) ForSyDe Group KTH 2007-2008
LicenseBSD-style (see the file LICENSE)
Maintainerforsyde-dev@ict.kth.se
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell98

ForSyDe.Shallow.Core.Signal

Description

This module defines the shallow-embedded Signal datatype and functions operating on it.

Synopsis

Documentation

data Signal a Source #

A signal is defined as a list of events. An event has a tag and a value. The tag of an event is defined by the position in the list. A signal is defined as an instance of the classes Read and Show. The signal 1 :- 2 :- NullS is represented as {1,2}.

Constructors

NullS 
a :- (Signal a) infixr 5 
Instances
Eq a => Eq (Signal a) Source # 
Instance details

Defined in ForSyDe.Shallow.Core.Signal

Methods

(==) :: Signal a -> Signal a -> Bool #

(/=) :: Signal a -> Signal a -> Bool #

Read a => Read (Signal a) Source # 
Instance details

Defined in ForSyDe.Shallow.Core.Signal

Show a => Show (Signal a) Source # 
Instance details

Defined in ForSyDe.Shallow.Core.Signal

Methods

showsPrec :: Int -> Signal a -> ShowS #

show :: Signal a -> String #

showList :: [Signal a] -> ShowS #

(-:) :: Signal a -> a -> Signal a infixr 5 Source #

The operator -: adds at an element to a signal at the tail.

(+-+) :: Signal a -> Signal a -> Signal a infixr 5 Source #

The operator +-+ concatinates two signals into one signal.

(!-) :: Signal a -> Int -> a infixr 5 Source #

signal :: [a] -> Signal a Source #

The function signal converts a list into a signal.

fromSignal :: Signal a -> [a] Source #

The function fromSignal converts a signal into a list.

unitS :: a -> Signal a Source #

The function unitS creates a signal with one value.

nullS :: Signal a -> Bool Source #

The function nullS checks if a signal is empty.

headS :: Signal a -> a Source #

The function headS gives the first value - the head - of a signal.

tailS :: Signal a -> Signal a Source #

The function tailS gives the rest of the signal - the tail.

atS :: Int -> Signal a -> a Source #

The function atS returns the n-th event in a signal. The numbering of events in a signal starts with 0. There is also an operator version of this function, '(!-)'.

takeS :: Int -> Signal a -> Signal a Source #

The function takeS returns the first n values of a signal.

dropS :: Int -> Signal a -> Signal a Source #

The function dropS drops the first $n$ values from a signal.

lengthS :: Signal b -> Int Source #

The function lengthS returns the length of a finite signal.

infiniteS :: (a -> a) -> a -> Signal a Source #

The function infiniteS creates an infinite signal. The first argument f is a function that is applied on the current value. The second argument x gives the first value of the signal.

Signal> takeS 5 (infiniteS (*3) 1)
{1,3,9,27,81} :: Signal Integer

copyS :: (Num a, Eq a) => a -> b -> Signal b Source #

The function copyS creates a signal with n values x.

selectS :: Int -> Int -> Signal a -> Signal a Source #

The function selectS takes three parameters, an offset, a stepsize and a signal and returns some elements of the signal such as in the following example:

Signal> selectS 2 3 (signal[1,2,3,4,5,6,7,8,9,10])
{3,6,9} :: Signal Integer

writeS :: Show a => Signal a -> [Char] Source #

The function writeS transforms a signal into a string of the following format:

Signal> writeS (signal[1,2,3,4,5])
"1n2n3n4n5n" :: [Char]

readS :: Read a => [Char] -> Signal a Source #

The function readS transforms a formatted string into a signal.

Signal> readS "1n2n3n4n5n" :: Signal Int
{1,2,3,4,5} :: Signal Int

fanS :: (Signal a -> Signal b) -> (Signal a -> Signal c) -> Signal a -> (Signal b, Signal c) Source #

The combinator fanS takes two processes p1 and p2 and and generates a process network, where a signal is split and processed by the processes p1 and p2.

foldrS :: (t -> p -> p) -> p -> Signal t -> p Source #

Folds all events in a signal to one value based on a reduction function.

allS :: (a -> Bool) -> Signal a -> Bool Source #

Checks if all events in a signal are satisfying a predicate function.