← all modules

Sky.Core.Random

Sky.Core.Random
  Sky.Core.Random — entropy-driven random helpers (Layer 3 Sky source).

Types
  type Seed = Seed Int

Values
  choice : List a -> Task Error (Maybe a)
      Pick one element from a list uniformly at random.  Returns
  float : Float -> Float -> Task Error Float
      Uniform random float in `[lo, hi)` (lo inclusive, hi exclusive).
  int : Int -> Int -> Task Error Int
      Uniform random integer in `[lo, hi]` inclusive on BOTH ends.
  range : Int -> Int -> Task Error Int
      Alias for `int` with a more obvious name when used in pipelines:
  seed : Int -> Seed
      `seed n` — construct a starting seed from an `Int`.  Identical
  seededChoice : Seed -> List a -> ( Maybe a, Seed )
      `seededChoice s list` — pick one element from a list, returning
  seededFloat : Seed -> ( Float, Seed )
      `seededFloat s` — uniform float in `[0, 1)`, returning the value
  seededInt : Seed -> Int -> Int -> ( Int, Seed )
      `seededInt s lo hi` — uniform integer in `[lo, hi]` inclusive,
  shuffle : List a -> Task Error (List a)
      Fisher-Yates shuffle.  Returns a new list with the same
  weighted : List ( Float, a ) -> Task Error (Maybe a)
      Weighted random pick.  Each tuple is `(weight, value)`.  Weights