|
|
|
|
|
Description |
There are two principal string types used internally by GHC:
FastString:
* A compact, hash-consed, representation of character strings.
* Comparison is O(1), and you can get a Unique.Unique from them.
* Generated by fsLit.
* Turn into Outputable.SDoc with Outputable.ftext.
LitString:
* Just a wrapper for the Addr# of a C string (Ptr CChar).
* Practically no operations.
* Outputing them is fast.
* Generated by sLit.
* Turn into Outputable.SDoc with Outputable.ptext
Use LitString unless you want the facilities of FastString.
|
|
Synopsis |
|
|
|
|
FastStrings
|
|
|
A FastString is an array of bytes, hashed to support fast O(1)
comparison. It is also associated with a character encoding, so that
we know how to convert a FastString to the local encoding, or to the
Z-encoding used by the compiler internally.
FastStrings support a memoized conversion to the Z-encoding via zEncodeFS.
| Constructors | | Instances | |
|
|
Construction
|
|
|
|
|
Creates a UTF-8 encoded FastString from a String
|
|
|
|
|
Creates a FastString from a UTF-8 encoded [Word8]
|
|
|
Create a FastString from an existing ForeignPtr; the difference
between this and mkFastStringBytes is that we don't have to copy
the bytes if the string is new to the table.
|
|
|
|
|
Creates a Z-encoded FastString from a String
|
|
|
|
Deconstruction
|
|
|
Unpacks and decodes the FastString
|
|
|
|
Encoding
|
|
|
Returns True if the FastString is Z-encoded
|
|
|
Returns a Z-encoded version of a FastString. This might be the
original, if it was already Z-encoded. The first time this
function is applied to a particular FastString, the results are
memoized.
|
|
Operations
|
|
|
|
|
Returns the length of the FastString in characters
|
|
|
Returns True if the FastString is empty
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Outputing
|
|
|
Outputs a FastString with no decoding at all, that is, you
get the actual bytes in the FastString written to the Handle.
|
|
Internal
|
|
|
|
|
Returns True if this FastString is not Z-encoded but already has
a Z-encoding cached (used in producing stats).
|
|
LitStrings
|
|
|
|
Construction
|
|
|
|
|
|
|
|
Deconstruction
|
|
|
|
Operations
|
|
|
|
Produced by Haddock version 2.6.1 |