[Haskell] ANN: global-variables-1.0
Jean-Marie Gaillourdet
jmg at gaillourdet.net
Wed Oct 12 20:08:44 CEST 2011
Hi,
I am pleased to announce the first public release of global-variables. A package
providing a global namespace for IORefs, MVars, and TVars.
Hackage URL: http://hackage.haskell.org/package/global-variables-1.0
Source: http://bitbucket.org/jmg/global-variables/
Description:
----------------
'Data.Global' provides a global namespace of 'IORef's, 'MVar's and
'TVar's. This namespace may be accessed in pure code. Yet reading and
writing to those 'IORef's, 'MVar's and 'TVar's happens still in their
respective monads.
'Data.Global' is designed to meet the following use cases:
* Simplify the declaration of top-level mutable variables, by
avoiding any pragmas as well as 'unsafePerformIO'.
* Avoid having to pass references explicitly throughout the program
in order to let distant parts communicate.
* Enable a communication by convention scheme, where e.g. different
libraries may communicate without code dependencies.
* Simplify the "configuration problem" - at least for code in the
IO monad.
Note, that this library does not encourage sloppy software design by
re-introducing all bad effects of global variables. Nevertheless,
sometimes global variables are a suitable solution to a problem. In
that case "Data.Global" simplifies and extends their handling
significantly.
Example:
-------------
> module Main where
>
> import Data.Global
> import Data.IORef
>
> counter :: IORef Int
> counter = declareIORef "Main.counter" 0
>
> main :: IO ()
> main = do
> counter `writeIORef` 1
> readIORef counter >>= print
Note absence of pragmas and of unsafePerformIO!
Future Plans:
------------------
* Support discovery/traversal of existing variables
* TemplateHaskell support to generate private and unique variable names.
Regards,
Jean
More information about the Haskell
mailing list