{-| Turn a list of generators into a generator of lists.
-}
combine : List (Generator a) -> Generator (List a)
combine generators =
case generators of
[] ->
constant []
g :: gs ->
Random.map2 (::) g (combine gs)
{-| Start with a list of generators, and turn them into a generator that returns a list.
-}
sequence : List (Generator a) -> Generator (List a)
sequence =
List.foldr (Random.map2 (::)) (Random.constant [])
The slightly different documentation can also be confusing.