once: memoization for IO actions and functions
Package provides single polymorphic function once
, that allows you
to memoize IO actions and functions, evaluating them at most once.
>>>
let mkStamp = (putStrLn "stamping" >> writeFile "/tmp/stamp" "") :: IO ()
>>>
-- onceStamp :: IO ()
>>>
onceStamp <- once mkStamp
>>>
-- onceStamp actually evaluates mkStamp it wraps first time.
>>>
onceStamp
stamping>>>
-- but second time result `()' is memoized, no action is performed.
>>>
onceStamp
>>>
-- we can memoize functions too
>>>
foo <- once $ \x -> print "foo" >> print (x :: Int)
>>>
-- action will be performed once for every distinct argument
>>>
foo 10
foo 10>>>
foo 10
10>>>
foo 4
foo 4
Downloads
- once-0.4.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1.0.0, 0.2, 0.3, 0.4 |
---|---|
Dependencies | base (>=4.7 && <5), containers (>=0.5), hashable (>=1.2), template-haskell (>=2.10), unordered-containers (>=0.2) [details] |
License | GPL-3.0-only |
Copyright | 2015-2018 Dmitry Bogatov |
Author | Dmitry Bogatov |
Maintainer | KAction@debian.org |
Category | Data |
Home page | https://gitlab.com/kaction/haskell-once |
Source repo | head: git clone https://gitlab.com/kaction/haskell-once |
Uploaded | by DmitryBogatov at 2018-12-01T21:06:30Z |
Distributions | LTSHaskell:0.4, NixOS:0.4, Stackage:0.4 |
Reverse Dependencies | 2 direct, 1 indirect [details] |
Downloads | 3278 total (25 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs available [build log] Last success reported on 2018-12-01 [all 1 reports] |