Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

The ROS Topic type and basic operations on Topics.

*Note*: Many of these operations have the same names as similar
operations on lists in the Prelude. The ambiguity may be resolved
using either qualification (e.g. ```
import qualified Ros.TopicUtil as
T
```

), an explicit import list, or a `hiding`

clause.

- newtype Topic m a = Topic {}
- head :: Functor m => Topic m a -> m a
- uncons :: Topic m a -> m (a, Topic m a)
- force :: Monad m => Topic m a -> m (Topic m a)
- cons :: Monad m => a -> Topic m a -> Topic m a
- tail :: Monad m => Topic m a -> Topic m a
- tails :: Monad m => Topic m a -> Topic m (Topic m a)
- filter :: Monad m => (a -> Bool) -> Topic m a -> Topic m a
- take :: Monad m => Int -> Topic m a -> m [a]
- take_ :: Monad m => Int -> Topic m a -> m ()
- drop :: Monad m => Int -> Topic m a -> Topic m a
- dropWhile :: Monad m => (a -> Bool) -> Topic m a -> Topic m a
- takeWhile :: Monad m => (a -> Bool) -> Topic m a -> m [a]
- break :: Monad m => (a -> Bool) -> Topic m a -> m ([a], Topic m a)
- splitAt :: Monad m => Int -> Topic m a -> m ([a], Topic m a)
- catMaybes :: Monad m => Topic m (Maybe a) -> Topic m a
- repeatM :: Monad m => m a -> Topic m a
- unfold :: Functor m => (b -> m (a, b)) -> b -> Topic m a
- newtype IterCont a b = IterCont (Maybe b, a -> IterCont a b)
- newtype IterContM m a b = IterContM (Maybe b, a -> m (IterContM m a b))
- yield :: b -> (a -> IterCont a b) -> IterCont a b
- skip :: (a -> IterCont a b) -> IterCont a b
- yieldM :: Monad m => b -> (a -> m (IterContM m a b)) -> m (IterContM m a b)
- skipM :: Monad m => (a -> m (IterContM m a b)) -> m (IterContM m a b)
- metamorph :: Monad m => (a -> IterCont a b) -> Topic m a -> Topic m b
- metamorphM :: Monad m => (a -> m (IterContM m a b)) -> Topic m a -> Topic m b
- bimetamorph :: Monad m => (a -> IterCont a b) -> (a -> IterCont a b) -> Topic m a -> Topic m b
- bimetamorphM :: Monad m => (a -> m (IterContM m a b)) -> (a -> m (IterContM m a b)) -> Topic m a -> Topic m b
- bimetamorphE :: Monad m => (a -> IterCont a b) -> (a -> IterCont a c) -> Topic m a -> Topic m (Either b c)
- bimetamorphME :: Monad m => (a -> m (IterContM m a b)) -> (a -> m (IterContM m a c)) -> Topic m a -> Topic m (Either b c)
- join :: (Functor m, Monad m) => Topic m (m a) -> Topic m a
- forever :: Monad m => Topic m a -> m b
- mapM :: (Functor m, Monad m) => (a -> m b) -> Topic m a -> Topic m b
- mapM_ :: Monad m => (a -> m ()) -> Topic m a -> m ()
- scan :: Monad m => (a -> b -> a) -> a -> Topic m b -> Topic m a
- showTopic :: (MonadIO m, Functor m, Show a) => Topic m a -> Topic m ()

# Documentation

A Topic is an infinite stream of values that steps between values
in a `Monad`

.

Functor m => Functor (Topic m) Source | |

Applicative m => Applicative (Topic m) Source |

force :: Monad m => Topic m a -> m (Topic m a) Source

Force evaluation of a topic until it produces a value.

take_ :: Monad m => Int -> Topic m a -> m () Source

Run a `Topic`

for the specified number of iterations, discarding
the values it produces.

drop :: Monad m => Int -> Topic m a -> Topic m a Source

`drop n t`

returns the suffix of `t`

after the first `n`

elements.

dropWhile :: Monad m => (a -> Bool) -> Topic m a -> Topic m a Source

`dropWhile p t`

returns the suffix of `t`

after all elements
satisfying predicate `p`

have been dropped.

takeWhile :: Monad m => (a -> Bool) -> Topic m a -> m [a] Source

`takeWhile p t`

returns the longest prefix (possibly empty) of `t`

all of whose elements satisfy the predicate `p`

.

break :: Monad m => (a -> Bool) -> Topic m a -> m ([a], Topic m a) Source

`break p t`

returns a tuple whose first element is the longest
prefix (possibly empty) of `t`

all of whose elements satisfy the
predicate `p`

, and whose second element is the remainder of the
`Topic`

.

splitAt :: Monad m => Int -> Topic m a -> m ([a], Topic m a) Source

`splitAt n t`

returns a tuple whose first element is the prefix of
`t`

of length `n`

, and whose second element is the remainder of the
`Topic`

.

repeatM :: Monad m => m a -> Topic m a Source

Repeatedly execute a monadic action feeding the values into a
`Topic`

.

A pair of an optional value and a continuation for producing more
such pairs. This type is used by `metamorph`

to implement a
streaming `unfold . fold`

composition.

newtype IterContM m a b Source

A pair of an optional value and a continuation with effects for
producing more such pairs. This type is used by `metamorphM`

to
implement a streaming `unfold . fold`

composition.

yield :: b -> (a -> IterCont a b) -> IterCont a b Source

Yield a value and a continuation in a metamorphism (used with
`metamorph`

).

skip :: (a -> IterCont a b) -> IterCont a b Source

Do not yield a value, but provide a continuation in a metamorphism
(used with `metamorph`

).

yieldM :: Monad m => b -> (a -> m (IterContM m a b)) -> m (IterContM m a b) Source

Yield a value and a continuation in a monad as part of a monadic
metamorphism (used with `metamorphM`

).

skipM :: Monad m => (a -> m (IterContM m a b)) -> m (IterContM m a b) Source

Do not yield a value, but provide a continuation in a metamorphism
(used with `metamorphM`

).

metamorph :: Monad m => (a -> IterCont a b) -> Topic m a -> Topic m b Source

A metamorphism (cf. Jeremy Gibbons) on `Topic`

s. This is an
*unfold* following a *fold* (i.e. `unfoldr . foldl`

), with the
expectation that partial results of the *unfold* may be returned
before the *fold* is completed. The supplied function produces a
optional value and a continuation when applied to an element of the
first `Topic`

. The value is returned by the new `Topic`

if it is
not `Nothing`

, and the continuation is used to produce the rest of
the returned `Topic`

.

metamorphM :: Monad m => (a -> m (IterContM m a b)) -> Topic m a -> Topic m b Source

Similar to `metamorph`

, but the metamorphism may have effects.

bimetamorph :: Monad m => (a -> IterCont a b) -> (a -> IterCont a b) -> Topic m a -> Topic m b Source

bimetamorphM :: Monad m => (a -> m (IterContM m a b)) -> (a -> m (IterContM m a b)) -> Topic m a -> Topic m b Source

bimetamorphE :: Monad m => (a -> IterCont a b) -> (a -> IterCont a c) -> Topic m a -> Topic m (Either b c) Source

bimetamorphME :: Monad m => (a -> m (IterContM m a b)) -> (a -> m (IterContM m a c)) -> Topic m a -> Topic m (Either b c) Source

join :: (Functor m, Monad m) => Topic m (m a) -> Topic m a Source

Removes one level of monadic structure from the values a `Topic`

produces.

mapM :: (Functor m, Monad m) => (a -> m b) -> Topic m a -> Topic m b Source

Map a monadic action over a `Topic`

.

mapM_ :: Monad m => (a -> m ()) -> Topic m a -> m () Source

Map a monadic action of a `Topic`

purely for its side
effects. This function will never return.