Safe Haskell | None |
---|---|
Language | GHC2021 |
Control.Monad.Flow
Synopsis
- type Flow (cat :: k -> k -> Type) = FlowT cat Identity
- mkFlow :: forall k (cat :: k -> k -> Type) x. (forall (a :: k). Sing a -> (x, Sigma k (TyCon (cat a)))) -> Flow cat x
- truncateFlow :: forall k (cat :: k -> k -> Type) x. SingKind k => Flow cat x -> State (Demote k) x
- toCoTravel :: forall k (cat :: k -> k -> Type) x. Category cat => Flow cat x -> Co (Travel cat) x
- fromCoTravel :: forall k (cat :: k -> k -> Type) x. Category cat => Co (Travel cat) x -> Flow cat x
- newtype FlowT (cat :: k -> k -> Type) (m :: Type -> Type) x = MkFlowT {}
- truncateFlowT :: forall k (cat :: k -> k -> Type) (m :: Type -> Type) x. (SingKind k, Monad m) => FlowT cat m x -> StateT (Demote k) m x
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
Monad.State
A value of State s x
describes:
- For each state
s1 :: s
, a next states2 :: s
- For each state
s1 :: s
, a valuex1 :: x
A value of Flow cat
describes:
- For each object
s1 :: k
, an arrowf :: cat s1 s2
starting froms1
and going to a next objects2
- For each object
s1 :: k
, a valuex1 :: 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 #
fromCoTravel :: forall k (cat :: k -> k -> Type) x. Category cat => Co (Travel cat) x -> Flow cat x Source #
Transformer version
newtype FlowT (cat :: k -> k -> Type) (m :: Type -> Type) x Source #
Transformer version of Flow
.