once

Version 0.4 revision 0 uploaded by DmitryBogatov.

Package meta

Synopsis
memoization for IO actions and functions
Description

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
Author
Dmitry Bogatov
Bug reports
n/a
Category
Data
Copyright
2015-2018 Dmitry Bogatov
Homepage
https://gitlab.com/kaction/haskell-once
Maintainer
KAction@debian.org
Package URL
n/a
Stability
n/a

Components