ST -is:module

The strict ST monad. The ST monad allows for destructive updates, but is escapable (unlike IO). A computation of type ST s a returns a value of type a, and execute in "thread" s. The s parameter is either
  • an uninstantiated type variable (inside invocations of runST), or
  • RealWorld (inside invocations of stToIO).
It serves to keep the internal states of different invocations of runST separate from each other and from invocations of stToIO. The >>= and >> operations are strict in the state (though not in values stored in the state). For example,
runST (writeSTRef _|_ v >>= f) = _|_
The lazy ST monad. The ST monad allows for destructive updates, but is escapable (unlike IO). A computation of type ST s a returns a value of type a, and executes in "thread" s. The s parameter is either
  • an uninstantiated type variable (inside invocations of runST), or
  • RealWorld (inside invocations of stToIO).
It serves to keep the internal states of different invocations of runST separate from each other and from invocations of stToIO. The >>= and >> operations are not strict in the state. For example,
runST (writeSTRef _|_ v >>= readSTRef _|_ >> return 2) = 2
The strict ST monad. The ST monad allows for destructive updates, but is escapable (unlike IO). A computation of type ST s a returns a value of type a, and execute in "thread" s. The s parameter is either
  • an uninstantiated type variable (inside invocations of runST), or
  • RealWorld (inside invocations of stToIO).
It serves to keep the internal states of different invocations of runST separate from each other and from invocations of stToIO. The >>= and >> operations are strict in the state (though not in values stored in the state). For example,
runST (writeSTRef _|_ v >>= f) = _|_
Symbolic version of the type T.
State of the decoder.
The strict ST monad. The ST monad allows for destructive updates, but is escapable (unlike IO). A computation of type ST s a returns a value of type a, and execute in "thread" s. The s parameter is either
  • an uninstantiated type variable (inside invocations of runST), or
  • RealWorld (inside invocations of stToIO).
It serves to keep the internal states of different invocations of runST separate from each other and from invocations of stToIO. The >>= and >> operations are strict in the state (though not in values stored in the state). For example,
runST (writeSTRef _|_ v >>= f) = _|_
Sao Tome and Principe
The strict state-transformer monad. A computation of type ST s a transforms an internal state indexed by s, and returns a value of type a. The s parameter is either
  • an uninstantiated type variable (inside invocations of runST), or
  • RealWorld (inside invocations of Control.Monad.ST.stToIO).
It serves to keep the internal states of different invocations of runST separate from each other and from invocations of Control.Monad.ST.stToIO. The >>= and >> operations are strict in the state (though not in values stored in the state). For example,
runST (writeSTRef _|_ v >>= f) = _|_
The strict state-transformer monad. A computation of type ST s a transforms an internal state indexed by s, and returns a value of type a. The s parameter is either
  • an uninstantiated type variable (inside invocations of runST), or
  • RealWorld (inside invocations of stToIO).
It serves to keep the internal states of different invocations of runST separate from each other and from invocations of stToIO. The >>= and >> operations are strict in the state (though not in values stored in the state). For example,
runST (writeSTRef _|_ v >>= f) = _|_
The state of a single particle is given by the position of the particle and the velocity of the particle.
Output a strict text.
Type-safe Static constructor macro for string literals. Example:
$(st "Foobar")
compiles to
unsafeCreate "Foobar" :: forall a. (IsString a, IsStaticText a) => Static a 6
where 6 is the string length obtained at compile time.
Run an ST calculation inside of a PrimMonad. This lets us avoid dispatching everything through the PrimMonad dictionary.
String is an alias for a list of characters. String constants in Haskell are values of type String. That means if you write a string literal like "hello world", it will have the type [Char], which is the same as String. Note: You can ask the compiler to automatically infer different types with the -XOverloadedStrings language extension, for example "hello world" :: Text. See IsString for more information. Because String is just a list of characters, you can use normal list functions to do basic string manipulation. See Data.List for operations on lists.

Performance considerations

[Char] is a relatively memory-inefficient type. It is a linked list of boxed word-size characters, internally it looks something like:
╭─────┬───┬──╮  ╭─────┬───┬──╮  ╭─────┬───┬──╮  ╭────╮
│ (:) │   │ ─┼─>│ (:) │   │ ─┼─>│ (:) │   │ ─┼─>│ [] │
╰─────┴─┼─┴──╯  ╰─────┴─┼─┴──╯  ╰─────┴─┼─┴──╯  ╰────╯
v               v               v
'a'             'b'             'c'
The String "abc" will use 5*3+1 = 16 (in general 5n+1) words of space in memory. Furthermore, operations like (++) (string concatenation) are O(n) (in the left argument). For historical reasons, the base library uses String in a lot of places for the conceptual simplicity, but library code dealing with user-data should use the text package for Unicode text, or the the bytestring package for binary data.