netwire-5.0.3: Functional reactive programming library

Copyright | (c) 2013 Ertugrul Soeylemez
License | BSD3
Maintainer | Ertugrul Soeylemez <es@ertes.de>
Safe Haskell | None
Language | Haskell2010

FRP.Netwire.Analyze

Contents

- Linear graphs
- Staircase graphs
- Peaks
- Debug

Description

Synopsis

- lAvg :: forall a t s e (m :: Type -> Type). (Fractional a, Fractional t, HasTime t s) => t -> Wire s e m a a
- lGraph :: forall a t s e (m :: Type -> Type). (Fractional a, Fractional t, HasTime t s) => [t] -> Wire s e m a [a]
- lGraphN :: forall a t s e (m :: Type -> Type). (Fractional a, Fractional t, HasTime t s) => t -> Int -> Wire s e m a [a]
- sAvg :: forall a t s e (m :: Type -> Type). (Fractional a, Fractional t, HasTime t s) => t -> Wire s e m a a
- sGraph :: forall t s e (m :: Type -> Type) a. (Fractional t, HasTime t s) => [t] -> Wire s e m a [a]
- sGraphN :: forall t s e (m :: Type -> Type) a. (Fractional t, HasTime t s) => t -> Int -> Wire s e m a [a]
- highPeak :: forall a s e (m :: Type -> Type). Ord a => Wire s e m a a
- highPeakBy :: forall a s e (m :: Type -> Type). (a -> a -> Ordering) -> Wire s e m a a
- lowPeak :: forall a s e (m :: Type -> Type). Ord a => Wire s e m a a
- lowPeakBy :: forall a s e (m :: Type -> Type). (a -> a -> Ordering) -> Wire s e m a a
- avgFps :: forall b t s e (m :: Type -> Type) a. (RealFloat b, HasTime t s) => Int -> Wire s e m a b
- framerate :: forall b t s e (m :: Type -> Type) a. (Eq b, Fractional b, HasTime t s, Monoid e) => Wire s e m a b

# Linear graphs

lAvg Source #

Arguments

:: forall a t s e (m :: Type -> Type). (Fractional a, Fractional t, HasTime t s) |
=> t | Interval size.
-> Wire s e m a a |

Calculate the average of the signal over the given interval (from now). This is done by calculating the integral of the corresponding linearly interpolated graph and dividing it by the interval length. See `linAvg` for details.

Linear interpolation can be slow. If you don't need it, you can use the staircase variant `sAvg`.

Example: `lAvg 2`

- Complexity: O(s) space, O(s) time wrt number of samples in the interval.
- Depends: now.

lGraph Source #

Arguments

:: forall a t s e (m :: Type -> Type). (Fractional a, Fractional t, HasTime t s) |
=> [t] | Data points to produce.
-> Wire s e m a [a] |

Produce a linearly interpolated graph for the given points in time, where the magnitudes of the points are distances from now.

Linear interpolation can be slow. If you don't need it, you can use the faster staircase variant `sGraph`.

Example: `lGraph [0, 1, 2]` will output the interpolated inputs at now, one second before now and two seconds before now.

- Complexity: O(s) space, O(n * log s) time, where s = number of samples in the interval, n = number of requested data points.
- Depends: now.

lGraphN Source #

Arguments

:: forall a t s e (m :: Type -> Type). (Fractional a, Fractional t, HasTime t s) |
=> t | Interval to graph from now.
-> Int | Number of data points to produce.
-> Wire s e m a [a] |

Graph the given interval from now with the given number of evenly distributed points in time. Convenience interface to `lGraph`.

Linear interpolation can be slow. If you don't need it, you can use the faster staircase variant `sGraphN`.

- Complexity: O(s) space, O(n * log s) time, where s = number of samples in the interval, n = number of requested data points.
- Depends: now.

# Staircase graphs

sAvg Source #

Arguments

:: forall a t s e (m :: Type -> Type). (Fractional a, Fractional t, HasTime t s) |
=> t | Interval size.
-> Wire s e m a a |

Calculate the average of the signal over the given interval (from now). This is done by calculating the integral of the corresponding staircase graph and dividing it by the interval length. See `scAvg` for details.

See also `lAvg`.

Example: `sAvg 2`

- Complexity: O(s) space, O(s) time wrt number of samples in the interval.
- Depends: now.

sGraph Source #

Arguments

:: forall t s e (m :: Type -> Type) a. (Fractional t, HasTime t s) |
=> [t] | Data points to produce.
-> Wire s e m a [a] |

Produce a staircase graph for the given points in time, where the magnitudes of the points are distances from now.

See also `lGraph`.

Example: `sGraph [0, 1, 2]` will output the inputs at now, one second before now and two seconds before now.

- Complexity: O(s) space, O(n * log s) time, where s = number of samples in the interval, n = number of requested data points.
- Depends: now.

sGraphN Source #

Arguments

:: forall t s e (m :: Type -> Type) a. (Fractional t, HasTime t s) |
=> t | Interval to graph from now.
-> Int | Number of data points to produce.
-> Wire s e m a [a] |

Graph the given interval from now with the given number of evenly distributed points in time. Convenience interface to `sGraph`.

See also `lGraphN`.

- Complexity: O(s) space, O(n * log s) time, where s = number of samples in the interval, n = number of requested data points.
- Depends: now.

# Peaks

highPeak :: forall a s e (m :: Type -> Type). Ord a => Wire s e m a a Source #

High peak.

- Depends: now.

highPeakBy :: forall a s e (m :: Type -> Type). (a -> a -> Ordering) -> Wire s e m a a Source #

High peak with respect to the given comparison function.

- Depends: now.

lowPeak :: forall a s e (m :: Type -> Type). Ord a => Wire s e m a a Source #

Low peak.

- Depends: now.

lowPeakBy :: forall a s e (m :: Type -> Type). (a -> a -> Ordering) -> Wire s e m a a Source #

Low peak with respect to the given comparison function.

- Depends: now.

# Debug

avgFps Source #

Arguments

:: forall b t s e (m :: Type -> Type) a. (RealFloat b, HasTime t s) |
=> Int | Number of samples.
-> Wire s e m a b |

Average framerate over the last given number of samples. One important thing to note is that the value of this wire will generally disagree with `sAvg` composed with `framerate`. This is expected, because this wire simply calculates the arithmetic mean, whereas `sAvg` will actually integrate the framerate graph.

Note: This wire is for debugging purposes only, because it exposes discrete time. Do not taint your application with discrete time.

- Complexity: O(n) time and space wrt number of samples.

framerate :: forall b t s e (m :: Type -> Type) a. (Eq b, Fractional b, HasTime t s, Monoid e) => Wire s e m a b Source #

Current framerate.

Note: This wire is for debugging purposes only, because it exposes discrete time. Do not taint your application with discrete time.

- Inhibits: when the clock stopped ticking.