Copyright | (c) Justin Le 2019 |
---|---|
License | BSD3 |
Maintainer | justin@jle.im |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Conduits that are useful for sampling and running optimizers.
Synopsis
- shuffling :: PrimMonad m => Gen (PrimState m) -> ConduitT a a m ()
- shufflingN :: PrimMonad m => Int -> Gen (PrimState m) -> ConduitT a a m ()
- sinkSampleReservoir :: forall m v a o. (PrimMonad m, Vector v a) => Int -> Gen (PrimState m) -> ConduitT a o m (v a)
- samplingN :: PrimMonad m => Int -> Gen (PrimState m) -> ConduitT a a m ()
- skipSampling :: PrimMonad m => Double -> Gen (PrimState m) -> ConduitT a a m ()
Sampling conduits
shuffling :: PrimMonad m => Gen (PrimState m) -> ConduitT a a m () Source #
Outputs a shuffled version of the input stream. Keeps entire input stream in memory.
NOTE: Pulls the entire input stream into memory first before outputting anything.
shufflingN :: PrimMonad m => Int -> Gen (PrimState m) -> ConduitT a a m () Source #
Takes the first N items out of the input stream, shuffles them in-memory, and outputs the shuffled result.
Leaves the rest of the items in the stream.
Use forever
to repeat multiple times until the stream is exhausted.
sinkSampleReservoir :: forall m v a o. (PrimMonad m, Vector v a) => Int -> Gen (PrimState m) -> ConduitT a o m (v a) Source #
Process an entire stream, and keep N random and shuffled items from that stream. Is O(N) memory.