Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eeue56/elm-lazy
https://github.com/eeue56/elm-lazy
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/eeue56/elm-lazy
- Owner: eeue56
- License: bsd-3-clause
- Created: 2017-06-30T22:37:58.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-26T16:40:09.000Z (over 6 years ago)
- Last Synced: 2024-10-30T01:38:15.752Z (3 months ago)
- Language: Elm
- Size: 7.81 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elm-lazy
This library provides a way of putting of computations until they are needed, allowing for expensive calculations later.
lazySum : Lazy Int
lazySum =
lazy (\() -> sum <| List.range 1 1000000)It also gives you a way of storing a computed value so that you do not need to re-compute it.
lazySum : Int -> Lazy Int
lazySum n =
lazy (\() -> sum <| List.range 0 n)lazySums : List Int -> List (Lazy Int)
lazySums sums =
List.map lazySum sums-- evaluates the head, before putting it back on the list
evaluteCurrentSum : List (Lazy Int) -> List (Lazy Int)
evaluteCurrentSum xs =
case xs of
head::rest -> Lazy.evaluate head :: rest
_ -> []## Notes
This is a library based originally on the old `Lazy` implementation. However, it is written entirely in pure Elm. The main difference is explicit memoization, as we no longer use side-effects to achieve laziness.