ForSyDe-3.0: ForSyDe's Haskell-embedded Domain Specific Language.Source codeContentsIndex
ForSyDe.Shallow.Signal
Portabilityportable
Stabilityexperimental
Maintainerforsyde-dev@ict.kth.se
Description
This module defines the shallow-embedded Signal datatype and functions operating on it.
Synopsis
data Signal a
= NullS
| a :- (Signal a)
(-:) :: Signal a -> a -> Signal a
(+-+) :: Signal a -> Signal a -> Signal a
(!-) :: Signal a -> Int -> a
signal :: [a] -> Signal a
fromSignal :: Signal a -> [a]
unitS :: a -> Signal a
nullS :: Signal a -> Bool
headS :: Signal a -> a
tailS :: Signal a -> Signal a
atS :: Int -> Signal a -> a
takeS :: Int -> Signal a -> Signal a
dropS :: Int -> Signal a -> Signal a
lengthS :: Signal b -> Int
infiniteS :: (a -> a) -> a -> Signal a
copyS :: Num a => a -> b -> Signal b
selectS :: Int -> Int -> Signal a -> Signal a
writeS :: Show a => Signal a -> [Char]
readS :: Read a => [Char] -> Signal a
fanS :: (Signal a -> Signal b) -> (Signal a -> Signal c) -> Signal a -> (Signal b, Signal c)
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)
show/hide Instances
Eq a => Eq (Signal a)
Read a => Read (Signal a)
Show a => Show (Signal a)
(-:) :: Signal a -> a -> Signal aSource
The operator '-:' adds at an element to a signal at the tail.
(+-+) :: Signal a -> Signal a -> Signal aSource
The operator +-+ concatinates two signals into one signal.
(!-) :: Signal a -> Int -> aSource
signal :: [a] -> Signal aSource
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 aSource
The function unitS creates a signal with one value.
nullS :: Signal a -> BoolSource
The function nullS checks if a signal is empty.
headS :: Signal a -> aSource
The function headS gives the first value - the head - of a signal.
tailS :: Signal a -> Signal aSource
The function tailS gives the rest of the signal - the tail.
atS :: Int -> Signal a -> aSource
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 aSource
The function takeS returns the first n values of a signal.
dropS :: Int -> Signal a -> Signal aSource
The function dropS drops the first $n$ values from a signal.
lengthS :: Signal b -> IntSource
The function lengthS returns the length of a finite signal.
infiniteS :: (a -> a) -> a -> Signal aSource

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 => a -> b -> Signal bSource
The function copyS creates a signal with n values x.
selectS :: Int -> Int -> Signal a -> Signal aSource

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 aSource

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.
Produced by Haddock version 2.1.0