This module uses many names from Prelude, so consider importing it qualified:
import Data.STM.TList (TList) import qualified Data.STM.TList as TList
- type TList a = TVar (TCell a)
- data TCell a
- empty :: STM (TList a)
- emptyIO :: IO (TList a)
- cons :: a -> TList a -> STM (TList a)
- append :: TList a -> a -> STM (TList a)
- appendList :: TList a -> [a] -> STM (TList a)
- fromList :: [a] -> STM (TList a, TList a)
- uncons :: STM b -> (a -> TList a -> STM b) -> TList a -> STM b
- null :: TList a -> STM Bool
- drop :: Int -> TList a -> STM (TList a)
- end :: TList a -> STM (TList a)
- length :: TList a -> STM Int
- foldl' :: (a -> b -> a) -> a -> TList b -> STM a
- toList :: TList a -> STM [a]
The TList type
O(1). Prepend an item to the list, returning the new beginning of the list.
O(1). Append an item to the list, returning the new write end.
TList normally points to a
TNil, a "hole" into which the next item
will be written. However, if it doesn't,
append will silently overwrite
the next item. It is up to the application to ensure that the
points to a
TNil, or that overwriting an item in this case is desirable.
O(n). Append a list of items, returning the new write end.
O(n). Convert a pure list to a
TList, returning the head (read end)
and tail (write end) of the list.
These functions traverse the list strictly. They examine the list as
it is now; they do not
retry when the end of the list is reached.
|:: STM b|
What to do if the list is empty
|-> (a -> TList a -> STM b)|
What to do with the item and the remainder of the list
|-> TList a|
List node to examine
|-> STM b|
O(n). Skip the given number of items. Return the end of the list if a
TNil is reached.
O(n). Traverse the list with an accumulator function and initial value.