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 v x. x -> Gen v x Unit

Yield a value

#runWidget Source

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

Run a Widget

#yieldAndThen Source

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

Yield a value, and then continue

#mapYield Source

mapYield :: forall v x y a. (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 v x a. 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 a v m x. 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 v a b. 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 v a b. 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 v x. Array x -> Gen v x Unit

Array to Generator conversion Sequentially generates all values in the list

#genToList Source

genToList :: forall v x a. 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 v x y a. (x -> y) -> GenWidget v x a -> GenWidget v y a

#mapContGenWidget Source

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

#pureYield Source

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

#widgetYield Source

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