An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

safe-globals

This library provides a way to declare IORefs, TVars, Chans, etc. at the top level of a module. Declarations are safe. User code does not invoke unsafePerformIO or compiler pragmas. Variables are ordinary module-level bindings. Their scope can be controlled through the usual module import/export mechanism. Unrelated code cannot interfere with private variables by guessing some global identifier. References are statically typed, and polymorphic references are statically forbidden. The implementation is simple, and closely follows existing common practice. This library does not prevent the software design problems caused by global state. Rather, it provides some implementation safety for those circumstances where global state really is necessary. Fundamentally this library just provides Template Haskell macros for the usual unsafePerformIO trick, so it is subject to the same caveats. In particular, linking a module and then loading the same module dynamically through the GHC API may produce two copies of the same top-level variable. See the documentation of unsafePerformIO for additional compiler-specific requirements. This library may not work properly on GHC before 7.4, due to a GHC bug: http://hackage.haskell.org/trac/ghc/ticket/5558

Ecosystem
hackage.haskell.org
Latest Release
0.1.1
about 14 years ago
Versions
2
Downloads
2,463 total
Dependent Repos
1
Links
Registry hackage.haskell.org
JSON API View JSON
CodeMeta codemeta.json
Package Details
PURL pkg:hackage/safe-globals
spec
License BSD-3-Clause
First Release over 14 years ago
Last Synced about 3 hours ago