This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Library for conveniently working with stateful computations
version 1.0.0
license MIT
native-modules False
elm-version 0.15.0 <= v < 0.16.0
Tag 1.0.0
Committed At 2015-06-22 19:49:23 UTC
elm-lang/core 2.1.0 <= v < 3.0.0 2.1.0

Modules

README

Stateful Build Status

A small library with primitives for working with stateful computations. This is neat when trying to imitate mutable variables, for example random number seeds or just generating automatically incrementing ids like so:

nextId : Stateful Int Int
nextId =
  Stateful.get `Stateful.andThen` \id ->
  Stateful.put (id + 1) `Stateful.andThen` \_ ->
  Stateful.return id

threeIds : List Int
threeIds =
  fst <| Stateful.run
    (Stateful.sequence
      [ nextId
      , nextId
      , nextId
      ])
    3
-- threeIds = [3, 4, 5]

The advantage here is that we don't need to manually thread a counter variable in a let binding.