String -> ByteString
O(n) Convert a String into a ByteString
For applications with large numbers of string literals, pack can be a bottleneck.
error stops execution and displays an error message.
Read an entire file lazily into a ByteString. The Handle will be held open until EOF is encountered.
Read an entire file lazily into a ByteString. Use 'text mode' on Windows to interpret newlines
Read an entire file strictly into a ByteString. This is far more efficient than reading the characters into a String and then using pack. It also may be more efficient than opening the file and reading it using hGet.
Read an entire file strictly into a ByteString. This is far more efficient than reading the characters into a String and then using pack. It also may be more efficient than opening the file and reading it using hGet. Files are read using 'binary mode' on Windows, for 'text mode' use the Char8 version of this function.
repeat x is an infinite ByteString, with x the value of every element.
When called, trace outputs the string in its first argument, before returning the second argument as its result. The trace function is not referentially transparent, and should only be used for debugging, or for monitoring execution. Some implementations of trace may decorate the string that's output to indicate that you're tracing. The function is implemented on top of putTraceMsg.
The read function reads input from a string, which must be completely consumed by the input process.
Format a variable number of arguments with the C-style formatting string. The return value is either String or (IO a).
The format string consists of ordinary characters and /conversion specifications/, which specify how to format one of the arguments to printf in the output string. A conversion specification begins with the character %, followed by one or more of the following flags:
> - left adjust (default is right adjust)
> + always use a sign (+ or -) for signed conversions
> 0 pad with zeroes rather than spaces
followed optionally by a field width:
> num field width
> * as num, but taken from argument list
followed optionally by a precision:
> .num precision (number of decimal places)
and finally, a format character:
> c character Char, Int, Integer, ...
> d decimal Char, Int, Integer, ...
> o octal Char, Int, Integer, ...
> x hexadecimal Char, Int, Integer, ...
> X hexadecimal Char, Int, Integer, ...
> u unsigned decimal Char, Int, Integer, ...
> f floating point Float, Double
> g general format float Float, Double
> G general format float Float, Double
> e exponent format float Float, Double
> E exponent format float Float, Double
> s string String
Mismatch between the argument types and the format string will cause an exception to be thrown at runtime.
Examples:
> > printf "%d\n" (23::Int)
> 23
> > printf "%s %s\n" "Hello" "World"
> Hello World
> > printf "%.2f\n" pi
> 3.14
Throw an IOError corresponding to the current socket error.
iterate f x returns an infinite ByteString of repeated applications of f to x:
> iterate f x == [x, f x, f (f x), ...]
O(n) replicate n x is a ByteString of length n with x the value of every element.
O(n) replicate n x is a ByteString of length n with x the value of every element. The following holds:
> replicate w c = unfoldr w (\u -> Just (u,u)) c
This implemenation uses memset(3)
O(1) cons is analogous to '(:)' for lists.
O(n) cons is analogous to (:) for lists, but of different complexity, as it requires a memcpy.
O(1) Unlike cons, 'cons\'' is strict in the ByteString that we are consing onto. More precisely, it forces the head and the first chunk. It does this because, for space efficiency, it may coalesce the new byte onto the first 'chunk' rather than starting a new 'chunk'.
So that means you can't use a lazy recursive contruction like this:
> let xs = cons\' c xs in xs
You can however use cons, as well as repeat and cycle, to build infinite lazy ByteStrings.
O(n) The intersperse function takes a Char and a ByteString and `intersperses' that Char between the elements of the ByteString. It is analogous to the intersperse function on Lists.
O(n) Append a Char to the end of a ByteString. Similar to cons, this function performs a memcpy.
Similar to printf, except that output is via the specified Handle. The return type is restricted to (IO a).
option requires argument
optional argument
The parse failed at the specified source location, with an error message.
setRequestVersion v req returns a new request, identical to req, but with its HTTP version set to v.
setResponseVersion v rsp returns a new response, identical to rsp, but with its HTTP version set to v.
scanl is similar to foldl, but returns a list of successive reduced values from the left. This function will fuse.
> scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
Note that
> last (scanl f z xs) == foldl f z xs.
scanl is similar to foldl, but returns a list of successive reduced values from the left:
> scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
Note that
> last (scanl f z xs) == foldl f z xs.
scanr is the right-to-left dual of scanl.
Marshal a Haskell string into a NUL terminated C wide string using temporary storage.
* the Haskell string may not contain any NUL characters
* the memory is freed when the subcomputation terminates (either normally or via an exception), so the pointer to the temporary storage must not be used after this.
Marshal a Haskell string into a NUL terminated C string using temporary storage.
* the Haskell string may not contain any NUL characters
* the memory is freed when the subcomputation terminates (either normally or via an exception), so the pointer to the temporary storage must not be used after this.
Marshal a Haskell string into a NUL terminated C string using temporary storage.
* the Haskell string may not contain any NUL characters
* the memory is freed when the subcomputation terminates (either normally or via an exception), so the pointer to the temporary storage must not be used after this.
Show more results