schedule-0.0: Schedule sub-computations to run later, in a pure way

Safe HaskellNone
LanguageHaskell2010

Data.Rsv.RRelMMap

Contents

Description

See Data.Rsv for an overview of what "reservation" data structures are.

This module implements a relative-key multi-map, where each structure has an idea of "the current key", each insert is indexed by a key-offset relative to the current, and many independent inserts may be performed on the same key.

Currently keys are constrainted by (RMMap k, Monoid k). If you have trouble finding a Monoid instance for a Num type, that's because it's not there; see https://wiki.haskell.org/Monoid#Examples on why. In practise, you can probably just wrap your Num in a Sum.

Synopsis

Documentation

data RRelMMap k a Source

empty :: (Ord k, Monoid k) => RRelMMap k a Source

An empty RRelMMap.

Read operations

current :: RRelMMap k a -> k Source

(!) :: Ord k => RRelMMap k a -> k -> [a] Source

Write operations

setCurrent :: Ord k => k -> RRelMMap k a -> RRelMMap k a Source

Advance to a given key

insertAfter :: (Ord k, Monoid k) => k -> a -> RRelMMap k a -> (Delete k a, RRelMMap k a) Source

type Delete k a = RRelMMap k a -> (Maybe a, RRelMMap k a) Source

A map-transition that removes and retrieves the earlier-added item. If the item was already removed, Nothing is returned instead.

deleteKey :: Ord k => k -> RRelMMap k a -> RRelMMap k a Source

Write operations in StateT

sSetCurrent :: (Ord k, Monad m) => k -> StateT (RRelMMap k a) m () Source

Same as setCurrent except in the StateT monad

sInsertAfter :: (Ord k, Monoid k, Monad m) => k -> a -> StateT (RRelMMap k a) m (SDelete k a m) Source

Same as insertAfter except in the StateT monad

type SDelete k a m = StateT (RRelMMap k a) m (Maybe a) Source

Same as Delete except in the StateT monad

sDeleteKey :: (Ord k, Monad m) => k -> StateT (RRelMMap k a) m () Source

Same as deleteKey except in the StateT monad