State package:base
State# is the primitive, unlifted type of states. It has one
type parameter, thus
State# RealWorld, or
State# s, where s is a type variable. The only purpose
of the type parameter is to keep different state threads separate. It
is represented by nothing at all.
Describes the behaviour of a thread when an asynchronous exception is
received.
Sometimes an external entity is a pure function, except that it passes
arguments and/or results via pointers. The function
unsafeLocalState permits the packaging of such entities as
pure functions.
The only IO operations allowed in the IO action passed to
unsafeLocalState are (a) local allocation (alloca,
allocaBytes and derived operations such as withArray
and withCString), and (b) pointer operations
(Foreign.Storable and Foreign.Ptr) on the pointers
to local storage, and (c) foreign functions whose only observable
effect is to read and/or write the locally allocated memory. Passing
an IO operation that does not obey these rules results in undefined
behaviour.
It is expected that this operation will be replaced in a future
revision of Haskell.
Return the current state of the codec.
Many codecs are not stateful, and in these case the state can be
represented as (). Other codecs maintain a state. For
example, UTF-16 recognises a BOM (byte-order-mark) character at the
beginning of the input, and remembers thereafter whether to use
big-endian or little-endian mode. In this case, the state of the codec
would include two pieces of information: whether we are at the
beginning of the stream (the BOM only occurs at the beginning), and if
not, whether to use the big or little-endian encoding.