polynomial-comonad
Safe HaskellNone
LanguageGHC2021

Control.Monad.Flow

Synopsis

Flow: Monad from a Category

type Flow (cat :: k -> k -> Type) = FlowT cat Identity Source #

Flow can be thought of as a generalization of the State Monad.

A value of State s x describes:

  • For each state s1 :: s, a next state s2 :: s
  • For each state s1 :: s, a value x1 :: x

A value of Flow cat describes:

  • For each object s1 :: k, an arrow f :: cat s1 s2 starting from s1 and going to a next object s2
  • For each object s1 :: k, a value x1 :: x

mkFlow :: forall k (cat :: k -> k -> Type) x. (forall (a :: k). Sing a -> (x, Sigma k (TyCon (cat a)))) -> Flow cat x Source #

truncateFlow :: forall k (cat :: k -> k -> Type) x. SingKind k => Flow cat x -> State (Demote k) x Source #

Forgets arrows of the underlying category from Flow cat, converting it to a simple State monad on objects of cat.

toCoTravel :: forall k (cat :: k -> k -> Type) x. Category cat => Flow cat x -> Co (Travel cat) x Source #

Co (Travel cat) is isomorphic to Flow cat

fromCoTravel :: forall k (cat :: k -> k -> Type) x. Category cat => Co (Travel cat) x -> Flow cat x Source #

Co (Travel cat) is isomorphic to Flow cat

Transformer version

newtype FlowT (cat :: k -> k -> Type) (m :: Type -> Type) x Source #

Transformer version of Flow.

Constructors

MkFlowT 

Fields

Instances

Instances details
Category cat => MonadTrans (FlowT cat) Source # 
Instance details

Defined in Control.Monad.Flow

Methods

lift :: Monad m => m a -> FlowT cat m a #

(Category cat, Monad m) => Applicative (FlowT cat m) Source # 
Instance details

Defined in Control.Monad.Flow

Methods

pure :: a -> FlowT cat m a #

(<*>) :: FlowT cat m (a -> b) -> FlowT cat m a -> FlowT cat m b #

liftA2 :: (a -> b -> c) -> FlowT cat m a -> FlowT cat m b -> FlowT cat m c #

(*>) :: FlowT cat m a -> FlowT cat m b -> FlowT cat m b #

(<*) :: FlowT cat m a -> FlowT cat m b -> FlowT cat m a #

Functor m => Functor (FlowT cat m) Source # 
Instance details

Defined in Control.Monad.Flow

Methods

fmap :: (a -> b) -> FlowT cat m a -> FlowT cat m b #

(<$) :: a -> FlowT cat m b -> FlowT cat m a #

(Category cat, Monad m) => Monad (FlowT cat m) Source # 
Instance details

Defined in Control.Monad.Flow

Methods

(>>=) :: FlowT cat m a -> (a -> FlowT cat m b) -> FlowT cat m b #

(>>) :: FlowT cat m a -> FlowT cat m b -> FlowT cat m b #

return :: a -> FlowT cat m a #

truncateFlowT :: forall k (cat :: k -> k -> Type) (m :: Type -> Type) x. (SingKind k, Monad m) => FlowT cat m x -> StateT (Demote k) m x Source #

Forgets arrows of the underlying category from FlowT cat m, converting it to a simple StateT on objects of cat.