cardano-data-0.1.0.0: Specialized data for Cardano project
Safe Haskell Safe-Inferred
Language Haskell2010

Data.Pulse

Synopsis

The class that defines operations on pulsers.

class Pulsable (pulse :: ( Type -> Type ) -> Type -> Type ) where Source #

let T be a Pulse structure. A Pulse struture is abstracted over a monad: m, and an answer type: t, so the concrete type of a pulse structure is written: (T m a). The Pulsable class supplies operations on the structure that allow its computation to be split into many discrete steps. One does this by running: "pulse p" or "pulseM p", depending upon whether the computation is monadic or not, to run a discrete step. The scheduling infrastructure needs to know nothing about what is going on inside the pulse structure.

Minimal complete definition

done , current , pulseM

Methods

done :: pulse m ans -> Bool Source #

current :: pulse m ans -> ans Source #

pulseM :: Monad m => pulse m ans -> m (pulse m ans) Source #

completeM :: Monad m => pulse m ans -> m ans Source #

Two reusable types that have Pulsable instances

data PulseMapM m ans where Source #

A Map based pulser.

Constructors

PulseMap :: ! Int -> !(ans -> k -> v -> m ans) -> !( Map k v) -> !ans -> PulseMapM m ans

data PulseListM m ans where Source #

A List based pulser

Constructors

PulseList :: ! Int -> !(ans -> a -> m ans) -> ![a] -> !ans -> PulseListM m ans

Virtual versions of PulseMapM and PulseListM specialized to be non-monadic.

type PulseMap ans = PulseListM Identity ans Source #

Type of a Map based pulser in the Identity monad.

type PulseList ans = PulseListM Identity ans Source #

Type of a List based pulser in the Identity monad.

pulseList :: Int -> (t1 -> t2 -> t1) -> [t2] -> t1 -> PulseListM Identity t1 Source #

Create List pulser structure in the Identity monad, a pure accumulator is lifted to a monadic one.

pulseMap :: Int -> (a -> k -> v -> a) -> Map k v -> a -> PulseMapM Identity a Source #

Create Map pulser structure in the Identity monad, a pure accumulator is lifted to a monadic one.

pulse :: Pulsable p => p Identity ans -> p Identity ans Source #

Pulse a structure in the Identity monad

complete :: Pulsable p => p Identity ans -> ans Source #

Complete a structure in the Identity monad

Monadic folds designed to be used inside pulsers.

foldlM' :: ( Foldable t, Monad m) => (ans -> k -> m ans) -> ans -> t k -> m ans Source #

A strict, monadic, version of foldl . It associates to the left.

foldlWithKeyM' :: Monad m => (a -> k -> b -> m a) -> a -> Map k b -> m a Source #

O(n) . A strict, monadic, version of foldlWithKey . Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value. Associates to the left.