haskus-utils-1.5: Haskus utility modules

Safe HaskellNone
LanguageHaskell2010

Haskus.Utils.MonadFlow

Contents

Description

IO control-flow with cache

Synopsis

Documentation

data MonadFlowF m a e Source #

MonadFlow Functor

Constructors

MonadEmit a e 
Eq v => MonadRead (m v) (v -> e) 
Eq v => MonadWith (m v) (v -> MonadFlow m a ()) e 
Instances
Functor (MonadFlowF m a) Source # 
Instance details

Defined in Haskus.Utils.MonadFlow

Methods

fmap :: (a0 -> b) -> MonadFlowF m a a0 -> MonadFlowF m a b #

(<$) :: a0 -> MonadFlowF m a b -> MonadFlowF m a a0 #

type MonadFlow m a r = Free (MonadFlowF m a) r Source #

runMonadFlow :: Monad m => MonadFlow m a r -> m (r, [a]) Source #

Run an MonadFlow

runM :: forall m v a. Eq v => m v -> MonadFlow m a v Source #

Get a variable in IO

Use withM to clearly limit the variable scope

withM :: Eq v => m v -> (v -> MonadFlow m a ()) -> MonadFlow m a () Source #

Read and use an IO variable in a delimited scope

emitM :: a -> MonadFlow m a () Source #

Emit a pure value

Cached control flow

data CachedMonadFlow m a Source #

Cached control-flow

Constructors

CachedMonadFlow 

Fields

  • cachedTree :: [MonadTree m a]

    Cached control-flow as an MonadTree

  • cachedContext :: forall b. m b -> m b

    Monadic context when performing an update (e.g. withSnapshot ctx)

Instances
Functor (CachedMonadFlow m) Source # 
Instance details

Defined in Haskus.Utils.MonadFlow

Methods

fmap :: (a -> b) -> CachedMonadFlow m a -> CachedMonadFlow m b #

(<$) :: a -> CachedMonadFlow m b -> CachedMonadFlow m a #

cacheMonadFlow :: Monad m => (forall b. m b -> m b) -> MonadFlow m a r -> m (CachedMonadFlow m a) Source #

Create a cache from an MonadFlow.

Execute the MonadFlow once to get cached values

cacheMonadFlowPure :: (forall b. m b -> m b) -> MonadFlow m a r -> CachedMonadFlow m a Source #

Create a cache from an MonadFlow.

This is the pure version: IO dependent nodes may not have any cached value

updateCachedMonadFlow :: Monad m => CachedMonadFlow m a -> m (CachedMonadFlow m a) Source #

Update a cached MonadFlow

updateCachedMonadFlowMaybe :: Monad m => CachedMonadFlow m a -> m (Maybe (CachedMonadFlow m a)) Source #

Update a cached MonadFlow