This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Making random values a little bit easier
version 1.0.1
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.0
Committed At 2018-02-03 20:30:27 UTC
mgold/elm-random-pcg 5.0.2 <= v < 6.0.0 5.0.2
elm-lang/html 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1

README

Random Pcg Pipeline

This is a package that makes getting random values a little bit easier in Elm. Its just like the package Chadtech/random-pipeline, except its adapted to use mgold/elm-random-pcg instead of the core random package.

Heres a side by side comparison between Random and Random.Pipeline

-- Random
modelGenerator : Generator Model
modelGenerator =
    Random.map4 Model
        positionGenerator
        enemiesGenerator
        uuidGenerator
        nameGenerator


init : Seed -> ( Model, Seed )
init =
    Random.step modelGenerator


-- Random.Pcg.Pipeline
import Random.Pcg.Pipeline exposing (from, with)

init : Seed -> ( Model, Seed )
init seed =
    Model
        |> from seed
        |> with positionGenerator
        |> with enemiesGenerator
        |> with uuidGenerator
        |> with nameGenerator

A little bit cleaner right? And what if we wanted to keep the seed in our Model too? Just use Random.Pipeline.finish

import Random.Pcg.Pipeline exposing (from, with, finish)

init : Seed -> Model
init seed =
    Model
        |> from seed
        |> with positionGenerator
        |> with enemiesGenerator
        |> with uuidGenerator
        |> with nameGenerator
        |> finish


type alias Model =
    { pos : Position
    , enemies : List Enemy
    , uuid : Uuid
    , name : String
    , seed : Seed
    }

It also has always that can hardcode values into your random generation.

import Random.Pcg.Pipeline exposing (from, with, finish, always)

update : Msg -> Model -> Model
update msg model =
    case msg of
        Restart ->
            Model
                |> from model.seed
                |> with positionGenerator
                |> with enemiesGenerator
                |> always model.uuid
                |> always model.name
                |> finish