String +base
A String is a list of characters. String constants in Haskell are values of type String.
The String type and associated operations.
Utilities for primitive marshalling of C strings.
The marshalling converts each Haskell character, representing a Unicode code point, to one or more bytes in a manner that, by default, is determined by the current locale. As a consequence, no guarantees can be made about the relative length of a Haskell string and its corresponding C string, and therefore all the marshalling routines include memory allocation. The translation between Unicode and the encoding of the current locale may be lossy.
String literal, with escapes interpreted
Parses and returns the specified string.
utility function converting a String to a show function that simply prepends the string unchanged.
A C string is a reference to an array of C characters terminated by NUL.
A string with explicit length information in bytes instead of a terminating NUL (allowing NUL characters in the middle of the string).
A C wide string is a reference to an array of C wide characters terminated by NUL.
A wide character string with explicit length information in CWchars instead of a terminating NUL (allowing NUL characters in the middle of the string).
A sample hash function for Strings. We keep multiplying by the golden ratio and adding. The implementation is:
> hashString = foldl' f golden
>
> magic = 0xdeadbeef
Where hashInt32 works just as hashInt shown above.
Knuth argues that repeated multiplication by the golden ratio will minimize gaps in the hash space, and thus it's a good choice for combining together multiple keys to form one.
Here we know that individual characters c are often small, and this produces frequent collisions if we use ord c alone. A particular problem are the shorter low ASCII and ISO-8859-1 character strings. We pre-multiply by a magic twiddle factor to obtain a good distribution. In fact, given the following test:
> testp :: Int32 -> Int
> testp k = (n - ) . length . group . sort . map hs . take n $ ls
>
> hs = foldl' f golden
> f m c = fromIntegral (ord c) * k + hashInt32 m
> n = 100000
We discover that testp magic = 0.
Class for string-like datastructures; used by the overloaded string extension (-foverloaded-strings in GHC).
This function is now deprecated. Please use mkCharConstr instead.
This function is now deprecated. Please use mkCharType instead.
Marshal a Haskell string into a NUL terminated C string.
* the Haskell string may not contain any NUL characters
* new storage is allocated for the C string and must be explicitly freed using Foreign.Marshal.Alloc.free or Foreign.Marshal.Alloc.finalizerFree.
Marshal a Haskell string into a C string (ie, character array) with explicit length information.
* new storage is allocated for the C string and must be explicitly freed using Foreign.Marshal.Alloc.free or Foreign.Marshal.Alloc.finalizerFree.
Marshal a Haskell string into a NUL terminated C string.
* the Haskell string may not contain any NUL characters
* new storage is allocated for the C string and must be explicitly freed using Foreign.Marshal.Alloc.free or Foreign.Marshal.Alloc.finalizerFree.
Show more results