Skip to content

sequence and combine seem to be two different implementations of the same function #28

@rlefevre

Description

@rlefevre
{-| 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions