Copyright | (c) 2018 Andrew Lelechenko |
---|---|

License | MIT |

Maintainer | Andrew Lelechenko <andrew.lelechenko@gmail.com> |

Safe Haskell | None |

Language | Haskell2010 |

Lazy, infinite stream with O(1) indexing.

## Synopsis

- data Chimera a
- index :: Chimera a -> Word -> a
- tabulate :: (Word -> a) -> Chimera a
- tabulateFix :: ((Word -> a) -> Word -> a) -> Chimera a
- tabulateM :: forall m a. Monad m => (Word -> m a) -> m (Chimera a)
- tabulateFixM :: forall m a. Monad m => ((Word -> m a) -> Word -> m a) -> m (Chimera a)
- mapWithKey :: (Word -> a -> b) -> Chimera a -> Chimera b
- traverseWithKey :: forall m a b. Monad m => (Word -> a -> m b) -> Chimera a -> m (Chimera b)
- zipWithKey :: (Word -> a -> b -> c) -> Chimera a -> Chimera b -> Chimera c
- zipWithKeyM :: forall m a b c. Monad m => (Word -> a -> b -> m c) -> Chimera a -> Chimera b -> m (Chimera c)

# Documentation

Representation of a lazy infinite stream, offering
indexing via `index`

in constant time.

## Instances

Functor Chimera Source # | |

Applicative Chimera Source # | Similar to |

Foldable Chimera Source # | |

Defined in Data.Chimera fold :: Monoid m => Chimera m -> m # foldMap :: Monoid m => (a -> m) -> Chimera a -> m # foldr :: (a -> b -> b) -> b -> Chimera a -> b # foldr' :: (a -> b -> b) -> b -> Chimera a -> b # foldl :: (b -> a -> b) -> b -> Chimera a -> b # foldl' :: (b -> a -> b) -> b -> Chimera a -> b # foldr1 :: (a -> a -> a) -> Chimera a -> a # foldl1 :: (a -> a -> a) -> Chimera a -> a # elem :: Eq a => a -> Chimera a -> Bool # maximum :: Ord a => Chimera a -> a # minimum :: Ord a => Chimera a -> a # | |

Traversable Chimera Source # | |

# Construction

tabulateFix :: ((Word -> a) -> Word -> a) -> Chimera a Source #

Create a stream from the unfixed function.

tabulateM :: forall m a. Monad m => (Word -> m a) -> m (Chimera a) Source #

Create a stream from the monadic function.

tabulateFixM :: forall m a. Monad m => ((Word -> m a) -> Word -> m a) -> m (Chimera a) Source #

Create a stream from the unfixed monadic function.

# Manipulation

mapWithKey :: (Word -> a -> b) -> Chimera a -> Chimera b Source #

Map over all indices and respective elements in the stream.

traverseWithKey :: forall m a b. Monad m => (Word -> a -> m b) -> Chimera a -> m (Chimera b) Source #

Traverse over all indices and respective elements in the stream.