Skip to content

Commit

Permalink
Merge branch 'master' of github.com:haskell-opengl/StateVar
Browse files Browse the repository at this point in the history
  • Loading branch information
ekmett committed Jan 17, 2016
2 parents 17ba6f9 + 83223e4 commit 45081c2
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 30 deletions.
83 changes: 69 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,78 @@
env:
- CABALVER=1.16 GHCVER=7.0.4
- CABALVER=1.16 GHCVER=7.2.2
- CABALVER=1.16 GHCVER=7.4.2
- CABALVER=1.16 GHCVER=7.6.3
- CABALVER=1.18 GHCVER=7.8.3
- CABALVER=1.20 GHCVER=7.8.4
- CABALVER=1.22 GHCVER=7.10.1
- CABALVER=head GHCVER=head

# It seems that we can't use the CABALVER and GHCVER environment variables in a
# toplevel addons.apt.packages section, so we have to duplicate things below.
matrix:
include:
- env: CABALVER=1.16 GHCVER=7.0.4
addons:
apt:
sources:
- hvr-ghc
packages:
- cabal-install-1.16
- ghc-7.0.4
- env: CABALVER=1.16 GHCVER=7.2.2
addons:
apt:
sources:
- hvr-ghc
packages:
- cabal-install-1.16
- ghc-7.2.2
- env: CABALVER=1.16 GHCVER=7.4.2
addons:
apt:
sources:
- hvr-ghc
packages:
- cabal-install-1.16
- ghc-7.4.2
- env: CABALVER=1.16 GHCVER=7.6.3
addons:
apt:
sources:
- hvr-ghc
packages:
- cabal-install-1.16
- ghc-7.6.3
- env: CABALVER=1.20 GHCVER=7.8.4
addons:
apt:
sources:
- hvr-ghc
packages:
- cabal-install-1.20
- ghc-7.8.4
- env: CABALVER=1.22 GHCVER=7.10.3
addons:
apt:
sources:
- hvr-ghc
packages:
- cabal-install-1.22
- ghc-7.10.3
- env: CABALVER=1.24 GHCVER=8.0.1
addons:
apt:
sources:
- hvr-ghc
packages:
- cabal-install-1.24
- ghc-8.0.1
- env: CABALVER=head GHCVER=head
addons:
apt:
sources:
- hvr-ghc
packages:
- cabal-install-head
- ghc-head
allow_failures:
- env: CABALVER=head GHCVER=head

before_install:
- sudo add-apt-repository -y ppa:hvr/ghc
- sudo apt-get update -qq
sudo: false

# The packages from the PPA don't put this into the PATH automatically.
install:
- sudo apt-get install -qq cabal-install-$CABALVER ghc-$GHCVER
- export PATH="/opt/cabal/$CABALVER/bin:/opt/ghc/$GHCVER/bin:$PATH"

before_script:
Expand Down
30 changes: 28 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
1.1
---
1.1.0.3
-------
* Removed a couple of redundant typeclass constraints.

1.1.0.2
-------
* Relaxed upper version bound for `transformers`.

1.1.0.1
-------
* Documentation changes only.

1.1.0.0
-------
* Melded the API of `foreign-var` 0.1 with the API of `StateVar` 1.0.1.1
* Introduced `HasUpdate`, which permits a wider array of uses of these combinators, including usecases that must update atomically.
* Switched to multi-parameter typeclasses. This permits `Ptr a` to be directly employed as an instance of `HasGetter`, `HasUpdate`, and `HasSetter`.

1.0.1.1
-------
* Infrastructure changes only.

1.0.1.0
-------
* Exposed `GettableStateVar`, `SettableStateVar` and `StateVar` constructors to make writing own instances possible.
* Added `Functor`, `Applicative` and `Monad` instances for `GettableStateVar`.
* Various infrastructure improvements.

1.0.0.0
-------
* Initial release.
6 changes: 3 additions & 3 deletions StateVar.cabal
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: StateVar
version: 1.1.0.1
version: 1.1.0.3
synopsis: State variables
description:
This package contains state variables, which are references in the IO monad,
like IORefs or parts of the OpenGL state.
homepage: https://github.com/haskell-opengl/StateVar
bug-reports: https://github.com/haskell-opengl/StateVar/issues
copyright: Copyright (C) 2014-2015 Edward A. Kmett, 2009-2014 Sven Panne
copyright: Copyright (C) 2014-2015 Edward A. Kmett, 2009-2015 Sven Panne
license: BSD3
license-file: LICENSE
author: Sven Panne and Edward Kmett
Expand All @@ -23,7 +23,7 @@ library
build-depends:
base >= 4 && < 5,
stm >= 2.0 && < 2.5,
transformers >= 0.2 && < 0.5
transformers >= 0.2 && < 0.6

default-language: Haskell2010
other-extensions:
Expand Down
20 changes: 9 additions & 11 deletions src/Data/StateVar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,21 @@ import Foreign.Storable

-- | A concrete implementation of a readable and writable state variable,
-- carrying one IO action to read the value and another IO action to write the
-- new value.
-- new value. This data type represents a piece of mutable, imperative state
-- with possible side-effects. These tend to encapsulate all sorts tricky
-- behavior in external libraries, and may well throw exceptions. Inhabitants
-- __should__ satsify the following properties:
--
-- This data type represents a piece of mutable, imperative state
-- with possible side-effects. These tend to encapsulate all sorts
-- tricky behavior in external libraries, and may well throw
-- exceptions.
--
-- Inhabitants __should__ satsify the following properties.
--
-- In the absence of concurrent mutation from other threads or a
-- thrown exception:
-- * In the absence of concurrent mutation from other threads or a thrown
-- exception:
--
-- @
-- do x <- 'get' v; v '$=' y; v '$=' x
-- @
--
-- should restore the previous state.
--
-- Ideally, in the absence of thrown exceptions:
-- * Ideally, in the absence of thrown exceptions:
--
-- @
-- v '$=' a >> 'get' v
Expand Down Expand Up @@ -196,6 +192,7 @@ instance HasSetter (TVar a) a where

infixr 2 $~, $~!

-- | This is the class of all updatable state variables.
class HasSetter t a => HasUpdate t a b | t -> a b where
-- | Transform the contents of a state variable with a given funtion.
($~) :: MonadIO m => t -> (a -> b) -> m ()
Expand Down Expand Up @@ -250,6 +247,7 @@ instance HasUpdate (TVar a) a a where
-- * HasGetter
--------------------------------------------------------------------

-- | This is the class of all readable state variables.
class HasGetter t a | t -> a where
get :: MonadIO m => t -> m a

Expand Down

0 comments on commit 45081c2

Please sign in to comment.