Module

Concur.Core.Gen

Package
purescript-concur-core
Repository
purescript-concur/purescript-concur-core

#GenStep Source

newtype GenStep v x a

Constructors

Instances

#GenWidget Source

type GenWidget v x a = Widget v { cont :: a, yield :: Maybe x }

#Gen Source

type Gen v x a = Free (GenStep v x) a

A Gen is a widget that also generates things

#WidgetGen Source

type WidgetGen v b a = Gen v (Widget v b) a

Sometimes it's useful to have Generators that generate Widgets

#yield Source

yield :: forall x v. x -> Gen v x Unit

Yield a value

#runWidget Source

runWidget :: forall a x v. Widget v a -> Gen v x a

Run a Widget

#yieldAndThen Source

yieldAndThen :: forall a x v. x -> Widget v (Gen v x a) -> Gen v x a

Yield a value, and then continue

#mapYield Source

mapYield :: forall a y x v. (x -> y) -> Gen v x a -> Gen v y a

A map over yielded values (of type X) The usual map is over the return value

#zipYield Source

zipYield :: forall a x v. Gen v x a -> Gen v (Tuple Int x) a

Convert a generator into one that tags its output with successive unique integers

#zipWidgetYield Source

zipWidgetYield :: forall x m v a. Functor m => Gen v (m x) a -> Gen v (m (Tuple Int x)) a

Convert a monadic generator into one that tags its output with successive unique integers Can also be specialised to :: WidgetGen v x a -> WidgetGen v (Tuple Int x) a

#genOrr Source

genOrr :: forall b a v. Monoid v => WidgetGen v a b -> Widget v (Either b a)

Collapse a Generator into one widget. For containers with dynamic children. Any new widgets generated are immediately inserted into the parent widget Returns either (Left b) when Gen ends, or Right a, when one of the children end.

#zipGenOrr Source

zipGenOrr :: forall b a v. Monoid v => WidgetGen v a b -> Widget v (Either b (Tuple Int a))

Like genOrr, collapses a Generator into one widget. However, any values returned by the children are tagged with an id (unique to this generator) Any new widgets generated are immediately inserted into the parent widget Returns either (Left b) when Gen ends, or (Tuple Int a), when one of the children end.

#listToGen Source

listToGen :: forall x v. Array x -> Gen v x Unit

Array to Generator conversion Sequentially generates all values in the list

#genToList Source

genToList :: forall a x v. Gen v x a -> Widget v (Array x)

Generator to Array conversion. Runs until generator ends, then returns all generated values in an array. Use it when you want to generate values, and then operate on them in one go

#mapYieldGenWidget Source

mapYieldGenWidget :: forall a y x v. (x -> y) -> GenWidget v x a -> GenWidget v y a

#mapContGenWidget Source

mapContGenWidget :: forall b a x v. (a -> b) -> GenWidget v x a -> GenWidget v x b

#pureYield Source

pureYield :: forall x v. x -> GenStep v x Unit

#widgetYield Source

widgetYield :: forall a x v. Maybe x -> Widget v a -> GenStep v x a