unboxed-references: A library for reference cells backed by unboxed-vectors

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

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 =
      print counter
      print mySum
      print strictModify

  -- |
  -- Runs a for loop each time modifying the reference cell to add
  -- one.
  counter :: Int
  counter =
   runST $
       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 $
        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 $
        ref <- newSTRefU 0
        modifySTRefU ref (\_ -> Unsafe.unsafePerformIO $ print "Got here!" >> pure 10)
        writeSTRefU ref 42
         readSTRefU ref

This gives the following:

> main
"Got here!"


Versions 0.1.0, 0.1.0
Change log CHANGELOG.md
Dependencies base (>= && <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-15T22:52:24Z


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees