safe-lazy-io-0.1: A library providing safe lazy IO features.Source codeContentsIndex
System.IO.Lazy.Input
Contents
Types
Running
Basic inputs
Combining multiple inputs lazily
Combining them in sequence
Combining them in parallel
Debugging
Synopsis
data LI a
run :: NFData sa => LI sa -> IO sa
run' :: NFData sa => LI (SIO sa) -> IO sa
runAsSIO :: NFData sa => LI sa -> SIO sa
runAsSIO' :: NFData sa => LI (SIO sa) -> SIO sa
pureLI :: a -> LI a
hGetContents :: Handle -> LI String
getContents :: LI String
readFile :: FilePath -> LI String
getChanContents :: Chan a -> LI [a]
append :: NFData sa => LI [sa] -> LI [sa] -> LI [sa]
concat :: NFData sa => [LI [sa]] -> LI [sa]
interleave :: NFData sa => LI [sa] -> LI [sa] -> LI [sa]
interleaveEither :: (NFData sa, NFData sb) => LI [sa] -> LI [sb] -> LI [Either sa sb]
zip :: (NFData sa, NFData sb) => LI [sa] -> LI [sb] -> LI [(sa, sb)]
zipWith :: (NFData sa, NFData sb) => (sa -> sb -> c) -> LI [sa] -> LI [sb] -> LI [c]
zipMaybesWith :: (NFData sa, NFData sb) => (Maybe sa -> Maybe sb -> c) -> LI [sa] -> LI [sb] -> LI [c]
zipHandles :: Handle -> Handle -> LI [(Char, Char)]
trace :: String -> LI a -> LI a
Types
data LI a Source

This the type lazy input data.

Note that the lazy input type (LI) is a member of Functor, this means that one can update the contents of the input with any pure function.

LI could be a strict monad and a strict applicative functor. However it is not a lazy monad nor a lazy applicative functor as required Haskell. Hopefully it is a lazy (pointed) functor at least.

show/hide Instances
Running
run :: NFData sa => LI sa -> IO saSource
Extract the data from a lazy input, this is commonly used to actually run the given process over lazy inputs. As in all the functions that requires a NFData instance this means the result will forced using rnf.
run' :: NFData sa => LI (SIO sa) -> IO saSource
Pretty much as run expect that one can use strict IOs (System.IO.Strict) to produce the final result.
runAsSIO :: NFData sa => LI sa -> SIO saSource
Pretty much as run but live in the SIO monad instead of IO.
runAsSIO' :: NFData sa => LI (SIO sa) -> SIO saSource
Pretty much as run' but live in the SIO monad instead of IO.
Basic inputs
pureLI :: a -> LI aSource
Any pure data can lifted as lazy input.
hGetContents :: Handle -> LI StringSource
Returns the contents of the given handle lazily.
getContents :: LI StringSource
Returns the contents of standard input lazily.
readFile :: FilePath -> LI StringSource
Like hGetContents but it takes a FilePath.
getChanContents :: Chan a -> LI [a]Source
Return a lazy list representing the contents of the supplied Chan, much like System.IO.hGetContents.
Combining multiple inputs lazily
Combining them in sequence
append :: NFData sa => LI [sa] -> LI [sa] -> LI [sa]Source
Sequence two lazy inputs that produces lists as one only list. Note that the resource management is precise. As soon as the beginning of the second input is required, the resource of the first input is released and the the second resource is acquired.
concat :: NFData sa => [LI [sa]] -> LI [sa]Source
Same as append but for a list of inputs.
Combining them in parallel
interleave :: NFData sa => LI [sa] -> LI [sa] -> LI [sa]Source
Takes two lazy inputs and returns a single interleaved lazy input. Note that this function is left biased, this is always the left canal that is read first. This function is rarely used directly with file contents since it mixes the two contents, one generally use some tagging to separate them back. Look at interleaveEither for such a function.
interleaveEither :: (NFData sa, NFData sb) => LI [sa] -> LI [sb] -> LI [Either sa sb]Source
Like interleave but it starts by tagging the left input by Left and right input by Right leading to lazy input of Eithers.
zip :: (NFData sa, NFData sb) => LI [sa] -> LI [sb] -> LI [(sa, sb)]Source

Combine two lazy inputs as a single lazy input of pairs.

Note that if one input list is short, excess elements of the longer list are discarded.

zipWith :: (NFData sa, NFData sb) => (sa -> sb -> c) -> LI [sa] -> LI [sb] -> LI [c]Source
zipWith generalize zip with any combining function.
zipMaybesWith :: (NFData sa, NFData sb) => (Maybe sa -> Maybe sb -> c) -> LI [sa] -> LI [sb] -> LI [c]Source
zipHandles :: Handle -> Handle -> LI [(Char, Char)]Source
A shorthand for \h1 h2-> zip (hGetContents h1) (hGetContents h2).
Debugging
trace :: String -> LI a -> LI aSource
Add debugging messages using the given string. This will returns the same lazy input but more verbose.
Produced by Haddock version 2.4.2