homepage: https://github.com/Boarders/unboxed-references
changelog-type: markdown
hash: 50004b5942cf48e776bdd50ad571415a6e144c9069f53c4f7c340fbda652f76a
test-bench-deps: {}
maintainer: callan.mcgill@gmail.com
synopsis: A library for reference cells backed by unboxed-vectors
changelog: |
  Changelog
  ==========

  ## [0.1.0] - 2019-12-15

  * Added STRef implementation
  * Added documentation example
basic-deps:
  unboxed-references: -any
  base: ! '>=4.12.0.0 && <4.14'
  vector: ! '>=0.12.0 && <0.13'
all-versions:
- 0.1.0
author: Callan McGill
latest: 0.1.0
description-type: haddock
description: |2-

  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
  @
license-name: BSD-3-Clause

Update from Hackage at 2019-12-16T14:37:29Z
Update from Hackage at 2019-12-16T14:37:29Z
