1
Fork 0
solar-conflux/purescript/run-supply
Matei Adriel 7932b58d1e
purescript(run-supply): feat: implemented everything (I think)
Signed-off-by: prescientmoon <git@moonythm.dev>
2021-08-08 01:47:45 +03:00
..
src/Run purescript(run-supply): feat: implemented everything (I think) 2021-08-08 01:47:45 +03:00
test purescript(run-supply): feat: implemented everything (I think) 2021-08-08 01:47:45 +03:00
.gitignore purescript(run-supply): feat: implemented everything (I think) 2021-08-08 01:47:45 +03:00
LICENSE purescript(run-supply): feat: implemented everything (I think) 2021-08-08 01:47:45 +03:00
packages.dhall purescript(run-supply): feat: implemented everything (I think) 2021-08-08 01:47:45 +03:00
README.md purescript(run-supply): feat: implemented everything (I think) 2021-08-08 01:47:45 +03:00
spago.dhall purescript(run-supply): feat: implemented everything (I think) 2021-08-08 01:47:45 +03:00
spago.test.dhall purescript(run-supply): feat: implemented everything (I think) 2021-08-08 01:47:45 +03:00

Supply

An effect useful for generating an infinite supply of values.

Example

-- Generates 2 values and adds them together
foo :: forall r. Run (SUPPLY Int r) Int
foo = ado
    a <- generate
    b <- generate
    in a + b

-- | Runs `foo` by providing 2 as the starting value and adding 3 to each subsequent call.
runnedFoo :: Int
runnedFoo
    = foo -- Run (SUPPLY Int ()) Int
    # runSupply
        ((+) 3) -- generates the next value
        2 -- initial value
    # extract -- Run () Int -> Int

For the full documentation check out pursuit

Development

Building the package

spago build

Running the test suite

spago -x ./spago.test.dhall test

If you think a particular helper would be an useful addition, feel free to open an issue.