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

- 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

Monad Stream # | |

Functor Stream # | |

Applicative Stream # | |

Foldable Stream # | |

Traversable Stream # | |

Distributive Stream # | |

Representable Stream # | |

Comonad Stream # | |

ComonadApply Stream # | |

Traversable1 Stream # | |

Alt Stream # | |

Apply Stream # | |

Extend Stream # | |

Foldable1 Stream # | |

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

Semigroup (Stream a) # | |

type Rep Stream # | |

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 #