Copyright | (C) 2011 Edward Kmett |
---|---|

License | BSD-style (see the file LICENSE) |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Stability | provisional |

Portability | portable |

Safe Haskell | Trustworthy |

Language | Haskell98 |

Anticausal streams implemented as non-empty skew binary random access lists

The Applicative zips streams, the monad diagonalizes

## Synopsis

- data Stream a
- (<|) :: a -> Stream a -> Stream a
- (!!) :: Stream a -> Integer -> a
- tail :: Stream a -> Stream a
- uncons :: Stream a -> (a, Stream a)
- drop :: Integer -> Stream a -> Stream a
- dropWhile :: (a -> Bool) -> Stream a -> Stream a
- span :: (a -> Bool) -> Stream a -> ([a], Stream a)
- break :: (a -> Bool) -> Stream a -> ([a], Stream a)
- split :: (a -> Bool) -> Stream a -> ([a], Stream a)
- splitW :: (Stream a -> Bool) -> Stream a -> ([a], Stream a)
- repeat :: a -> Stream a
- insert :: Ord a => a -> Stream a -> Stream a
- insertBy :: (a -> a -> Ordering) -> a -> Stream a -> Stream a
- adjust :: Integer -> (a -> a) -> Stream a -> Stream a
- update :: Integer -> a -> Stream a -> Stream a
- from :: Num a => a -> Stream a
- indexed :: Stream a -> Stream (Integer, a)
- interleave :: Stream a -> Stream a -> Stream a

# Documentation

## Instances

Monad Stream # | |

Functor Stream # | |

Applicative Stream # | |

Foldable Stream # | |

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

Traversable Stream # | |

Distributive Stream # | |

Representable Stream # | |

Comonad Stream # | |

ComonadApply Stream # | |

Traversable1 Stream # | |

Foldable1 Stream # | |

Alt Stream # | |

Apply Stream # | |

Extend Stream # | |

Show a => Show (Stream a) # | |

Semigroup (Stream a) # | |

type Rep Stream # | |

Defined in Data.Stream.Infinite.Skew |

split :: (a -> Bool) -> Stream a -> ([a], Stream a) #

*(O(n), O(log n))* split at _some_ edge where function goes from False to True.
best used with a monotonic function

splitW :: (Stream a -> Bool) -> Stream a -> ([a], Stream a) #

*(O(n), O(log n))* split at _some_ edge where function goes from False to True.
best used with a monotonic function

splitW p xs = (map extract &&& fmap (fmap extract)) . split p . duplicate

insertBy :: (a -> a -> Ordering) -> a -> Stream a -> Stream a #

*O(n)*. Finds the split in O(log n), but then has to recons

adjust :: Integer -> (a -> a) -> Stream a -> Stream a #

*O(log n)* Change the value of the nth entry in the future

interleave :: Stream a -> Stream a -> Stream a #