Copyright | (c) ForSyDe Group KTH 2007-2008 |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | forsyde-dev@ict.kth.se |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell98 |
This module defines the shallow-embedded Signal
datatype and
functions operating on it.
Synopsis
- data 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, Eq 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)
- foldrS :: (t -> p -> p) -> p -> Signal t -> p
- allS :: (a -> Bool) -> Signal a -> Bool
Documentation
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}.
(-:) :: 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.
fromSignal :: Signal a -> [a] Source #
The function fromSignal
converts a signal into a list.
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.
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
.