tangle-0.1: Heterogenous memoisation monad
Safe HaskellNone
LanguageHaskell2010

Control.Monad.Tangle

Synopsis

Documentation

newtype TangleFT t f m a Source #

TangleFT is a higher-kinded heterogeneous memoisation monad transformer. t represents the shape of the underlying data structure, and f is the wrapper type of each field. This monad represents computations that depend on the contents of t f.

Constructors

TangleFT 

Fields

Instances

Instances details
MonadTrans (TangleFT t f) Source # 
Instance details

Defined in Control.Monad.Tangle

Methods

lift :: Monad m => m a -> TangleFT t f m a #

Monad m => Monad (TangleFT t f m) Source # 
Instance details

Defined in Control.Monad.Tangle

Methods

(>>=) :: TangleFT t f m a -> (a -> TangleFT t f m b) -> TangleFT t f m b #

(>>) :: TangleFT t f m a -> TangleFT t f m b -> TangleFT t f m b #

return :: a -> TangleFT t f m a #

Functor m => Functor (TangleFT t f m) Source # 
Instance details

Defined in Control.Monad.Tangle

Methods

fmap :: (a -> b) -> TangleFT t f m a -> TangleFT t f m b #

(<$) :: a -> TangleFT t f m b -> TangleFT t f m a #

Monad m => Applicative (TangleFT t f m) Source # 
Instance details

Defined in Control.Monad.Tangle

Methods

pure :: a -> TangleFT t f m a #

(<*>) :: TangleFT t f m (a -> b) -> TangleFT t f m a -> TangleFT t f m b #

liftA2 :: (a -> b -> c) -> TangleFT t f m a -> TangleFT t f m b -> TangleFT t f m c #

(*>) :: TangleFT t f m a -> TangleFT t f m b -> TangleFT t f m b #

(<*) :: TangleFT t f m a -> TangleFT t f m b -> TangleFT t f m a #

MonadIO m => MonadIO (TangleFT t f m) Source # 
Instance details

Defined in Control.Monad.Tangle

Methods

liftIO :: IO a -> TangleFT t f m a #

(Monad m, Semigroup a) => Semigroup (TangleFT t f m a) Source # 
Instance details

Defined in Control.Monad.Tangle

Methods

(<>) :: TangleFT t f m a -> TangleFT t f m a -> TangleFT t f m a #

sconcat :: NonEmpty (TangleFT t f m a) -> TangleFT t f m a #

stimes :: Integral b => b -> TangleFT t f m a -> TangleFT t f m a #

(Monad m, Monoid a) => Monoid (TangleFT t f m a) Source # 
Instance details

Defined in Control.Monad.Tangle

Methods

mempty :: TangleFT t f m a #

mappend :: TangleFT t f m a -> TangleFT t f m a -> TangleFT t f m a #

mconcat :: [TangleFT t f m a] -> TangleFT t f m a #

hitchF Source #

Arguments

:: Monad m 
=> (forall h g. Functor g => (h a -> g (h a)) -> t h -> g (t h))

van Laarhoven lens

-> TangleFT t f m (f a) 

Obtain a value from the tangle. The result gets memoised.

evalTangleFT :: (ApplicativeB t, Functor m) => TangleFT t f m a -> t (Compose (TangleFT t f m) f) -> m a Source #

liftTangles :: (FunctorB b, Functor m) => b (TangleT b m) -> b (Compose (TangleT b m) Identity) Source #

Lift a collection of TangleTs so that it fits the argument of runTangleFT.

blank :: ApplicativeB b => b (Compose Maybe f) Source #

A product where all the elements are Compose Nothing

hitch Source #

Arguments

:: Monad m 
=> (forall h g. Functor g => (h a -> g (h a)) -> t h -> g (t h))

van Laarhoven lens

-> TangleT t m a 

Bare variant of hitchF

gather :: (TraversableB t, Monad m) => TangleFT t f m (t f) Source #

Collect all results in the tangle.

type TangleF t f = TangleFT t f Identity Source #

Non-transformer version of TangleFT

evalTangleF :: ApplicativeB t => TangleF t f a -> t (Compose (TangleF t f) f) -> a Source #

type TangleT t = TangleFT t Identity Source #

Bare version of TangleFT

evalTangleT :: (Functor m, ApplicativeB t) => TangleT t m a -> t (TangleT t m) -> m a Source #

type Tangle t = TangleFT t Identity Identity Source #

Bare non-transformer tangle

evalTangle :: ApplicativeB t => Tangle t a -> t (Tangle t) -> a Source #