unboxed-references: A library for reference cells backed by unboxed-vectors
This package contains an interface to references backed by unboxed vectors
For an example of how to use it:
module Main where import Data.STRef.Unboxed import Control.Monad.ST main :: IO () main = do print counter print mySum print strictModify -- | -- Runs a for loop each time modifying the reference cell to add -- one. counter :: Int counter = runST $ do ref <- newSTRefU 0 for_ [1..100] $ modifySTRefU ref (+ 1) readSTRefU ref -- | -- Runs a for loop to add all the numbers between 1 and 10. mySum :: Int mySum = runST $ do ref <- newSTRefU 0 for_ [1..10] $ \i -> modifySTRefU ref (+ i) readSTRefU ref -- | -- This shows that modifySTRefU is strict in its argument. strictModify :: Int strictModify = runST $ do ref <- newSTRefU 0 modifySTRefU ref (\_ -> Unsafe.unsafePerformIO $ print "Got here!" >> pure 10) writeSTRefU ref 42 readSTRefU ref
This gives the following:
> main 100 55 "Got here!" 42
Downloads
- unboxed-references-0.1.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
Versions [RSS] | 0.1.0 |
---|---|
Change log | CHANGELOG.md |
Dependencies | base (>=4.12.0.0 && <4.14), unboxed-references, vector (>=0.12.0 && <0.13) [details] |
License | BSD-3-Clause |
Copyright | 2019 |
Author | Callan McGill |
Maintainer | callan.mcgill@gmail.com |
Category | Data |
Home page | https://github.com/Boarders/unboxed-references |
Bug tracker | https://github.com/Boarders/unboxed-references/issues |
Source repo | head: git clone https://github.com/Boarders/unboxed-references |
Uploaded | by callanmcgill at 2019-12-16T14:29:48Z |
Distributions | |
Executables | example |
Downloads | 359 total (7 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs available [build log] Last success reported on 2019-12-16 [all 1 reports] |