Module

Concur.Core.Gen

#GenStep

newtype GenStep v x a

Constructors

Instances

#GenWidget

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

#Gen

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

A Gen is a widget that also generates things

#WidgetGen

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

Sometimes it's useful to have Generators that generate Widgets

#yield

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

Yield a value

#runWidget

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

Run a Widget

#yieldAndThen

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

Yield a value, and then continue

#mapYield

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

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

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

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

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

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

Array to Generator conversion Sequentially generates all values in the list

#genToList

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

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

#mapContGenWidget

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

#pureYield

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

#widgetYield

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

Modules