This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.

Random.Function

List of Function Generators

Generators

func : Generator b -> Generator (a -> b)

Generates a random function of one argument given a generator for the output.

func2 : Generator c -> Generator (a -> b -> c)

Generates a random function of two arguments given a generator for the output.

func3 : Generator d -> Generator (a -> b -> c -> d)

Generates a random function of three arguments given a generator for the output.

func4 : Generator e -> Generator (a -> b -> c -> d -> e)

Generates a random function of four arguments given a generator for the output.

func5 : Generator f -> Generator (a -> b -> c -> d -> e -> f)

Generates a random function of five arguments given a generator for the output.

func6 : Generator g -> Generator (a -> b -> c -> d -> e -> f -> g)

Generates a random function of six arguments given a generator for the output.

Infix operators

module Random.Function where
{-| List of Function Generators

# Generators
@docs func, func2, func3, func4, func5, func6

# Infix operators
@docs (<<<), (>>>)

-}

import Random exposing (Generator, generate, customGenerator)

{-| Generates a random function of one argument given a generator for the output.
-}
func : Generator b -> Generator (a -> b)
func generatorB =
  customGenerator <|
    (\seed ->
        let (valueB, seed1) = generate generatorB seed
        in
          ((\a -> valueB), seed1))


{-| Generates a random function of two arguments given a generator for the output.
-}
func2 : Generator c -> Generator (a -> b -> c)
func2 generatorC =
  func (func generatorC)


{-| Generates a random function of three arguments given a generator for the output.
-}
func3 : Generator d -> Generator (a -> b -> c -> d)
func3 generatorD =
  func (func2 generatorD)


{-| Generates a random function of four arguments given a generator for the output.
-}
func4 : Generator e -> Generator (a -> b -> c -> d -> e)
func4 generatorE =
  func (func3 generatorE)


{-| Generates a random function of five arguments given a generator for the output.
-}
func5 : Generator f -> Generator (a -> b -> c -> d -> e -> f)
func5 generatorF =
  func (func4 generatorF)


{-| Generates a random function of six arguments given a generator for the output.
-}
func6 : Generator g -> Generator (a -> b -> c -> d -> e -> f -> g)
func6 generatorG =
  func (func5 generatorG)


infixl 9 >>>
{-| Compose two function generators. Analogous to `>>`
-}
(>>>) : Generator (a -> b) -> Generator (b -> c) -> Generator (a -> c)
(>>>) generatorAB generatorBC =
  customGenerator <|
    (\seed ->
        let (f, seed1) = generate generatorAB seed
            (g, seed2) = generate generatorBC seed1
        in
          (f >> g, seed2))


infixr 9 <<<
{-| Compose two function generators. Analogous to `<<`
-}
(<<<) : Generator (b -> c) -> Generator (a -> b) -> Generator (a -> c)
(<<<) generatorBC generatorAB =
  customGenerator <|
    (\seed ->
        let (f, seed1) = generate generatorAB seed
            (g, seed2) = generate generatorBC seed1
        in
          (f >> g, seed2))