variant-1.0: Variant and EADT
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Variant.ContFlow

Description

Continuation based control-flow

Synopsis

Documentation

newtype ContFlow (xs :: [Type]) r Source #

A continuation based control-flow

Constructors

ContFlow (ContTuple xs r -> r) 

type family ContTuple (xs :: [Type]) r where ... Source #

Convert a list of types into the actual data type representing the continuations.

Equations

ContTuple xs r = Tuple (ToMultiCont xs r) 

(>:>) :: MultiCont a => a -> ContTuple (MultiContTypes a) r -> r infixl 0 Source #

Bind a multi-continuable type to a tuple of continuations

(>-:>) :: (MultiCont a, MultiContTypes a ~ '[b]) => a -> (b -> r) -> r infixl 0 Source #

Bind a single-continuable type to a 1-tuple of continuations

(>%:>) :: (MultiCont a, ReorderTuple ts (ContTuple (MultiContTypes a) r)) => a -> ts -> r infixl 0 Source #

Bind a multi-continuable type to a tuple of continuations and reorder fields if necessary

(>::>) :: ContFlow xs r -> ContTuple xs r -> r infixl 0 Source #

Bind a flow to a tuple of continuations

(>:-:>) :: ContFlow '[a] r -> (a -> r) -> r infixl 0 Source #

Bind a flow to a 1-tuple of continuations

(>:%:>) :: forall ts xs r. ReorderTuple ts (ContTuple xs r) => ContFlow xs r -> ts -> r infixl 0 Source #

Bind a flow to a tuple of continuations and reorder fields if necessary

type family ToMultiCont xs r where ... Source #

Equations

ToMultiCont '[] r = '[] 
ToMultiCont (x ': xs) r = (x -> r) ': ToMultiCont xs r 

class MultiCont a where Source #

A multi-continuable type

Associated Types

type MultiContTypes a :: [Type] Source #

Methods

toCont :: a -> ContFlow (MultiContTypes a) r Source #

Convert a data into a multi-continuation

toContM :: Monad m => m a -> ContFlow (MultiContTypes a) (m r) Source #

Convert a data into a multi-continuation (monadic)

Instances

Instances details
ContVariant xs => MultiCont (V xs) Source # 
Instance details

Defined in Data.Variant

Associated Types

type MultiContTypes (V xs) :: [Type] Source #

Methods

toCont :: V xs -> ContFlow (MultiContTypes (V xs)) r Source #

toContM :: Monad m => m (V xs) -> ContFlow (MultiContTypes (V xs)) (m r) Source #

(Functor (VariantF xs), ContVariant (ApplyAll (EADT xs) xs)) => MultiCont (EADT xs) Source #

MultiCont instance

>>> let f x = toCont x >::> (const "[]", \(ConsF u us) -> u ++ ":" ++ f us)
>>> f a
"Hello:World:[]"
Instance details

Defined in Data.Variant.EADT

Associated Types

type MultiContTypes (EADT xs) :: [Type] Source #

Methods

toCont :: EADT xs -> ContFlow (MultiContTypes (EADT xs)) r Source #

toContM :: Monad m => m (EADT xs) -> ContFlow (MultiContTypes (EADT xs)) (m r) Source #

ContVariant (ApplyAll e xs) => MultiCont (VariantF xs e) Source # 
Instance details

Defined in Data.Variant.VariantF

Associated Types

type MultiContTypes (VariantF xs e) :: [Type] Source #

Methods

toCont :: VariantF xs e -> ContFlow (MultiContTypes (VariantF xs e)) r Source #

toContM :: Monad m => m (VariantF xs e) -> ContFlow (MultiContTypes (VariantF xs e)) (m r) Source #