Copyright | (c) Ivan Lazar Miljenovic |
---|---|
License | MIT |
Maintainer | Ivan.Miljenovic@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
- spsort :: (Ord a, Monad m) => SP a a m ()
- spsortBy :: Monad m => (a -> a -> Ordering) -> SP a a m ()
- spsortOn :: (Ord b, Monad m) => (a -> b) -> SP a a m ()
- spfilesort :: (Binary a, Ord a, MonadResource m, MonadMask m) => Maybe Int -> Maybe FilePath -> P () a a () m (SPResult IOException)
- spfilesortBy :: (Binary a, MonadResource m, MonadMask m) => (a -> a -> Ordering) -> Maybe Int -> Maybe FilePath -> P () a a () m (SPResult IOException)
In-memory sorting
These Quivers require reading all the values from the quiver before being able to sort them. As such, it is highly recommended you only use them for short streams.
spsortBy :: Monad m => (a -> a -> Ordering) -> SP a a m () Source
Use the specified comparison function to sort the values.
spsortOn :: (Ord b, Monad m) => (a -> b) -> SP a a m () Source
Use the provided function to be able to compare values.
File-based sorting
For large Quivers it may not be possible to sort the entire stream in memory. As such, these functions work by sorting chunks of the stream and storing them in temporary files before merging them all together.
spfilesort :: (Binary a, Ord a, MonadResource m, MonadMask m) => Maybe Int -> Maybe FilePath -> P () a a () m (SPResult IOException) Source
Use external files to temporarily store partially sorted results (splitting into chunks of the specified size if one is provided).
These files are stored inside the specified directory if provided; if no such directory is provided then the system temporary directory is used.
spfilesortBy :: (Binary a, MonadResource m, MonadMask m) => (a -> a -> Ordering) -> Maybe Int -> Maybe FilePath -> P () a a () m (SPResult IOException) Source
Use external files to temporarily store partially sorted (using the comparison function) results (splitting into chunks of the specified size if one is provided).
These files are stored inside the specified directory if provided; if no such directory is provided then the system temporary directory is used.