Skip to content

Commit

Permalink
Support StateVar 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ekmett committed Mar 9, 2015
1 parent 2df5e60 commit aa24021
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.markdown
@@ -1,3 +1,7 @@
1.3
---
* We've merged the `foreign-var` and `StateVar` packages. Transferring support to `StateVar`.

1.2.2.1
-------
* Fixed redundant import warnings on GHC 7.10.
Expand Down
14 changes: 7 additions & 7 deletions contravariant.cabal
@@ -1,6 +1,6 @@
name: contravariant
category: Control, Data
version: 1.2.2.1
version: 1.3
license: BSD3
cabal-version: >= 1.6
license-file: LICENSE
Expand All @@ -23,23 +23,23 @@ source-repository head

flag tagged
description:
You can disable the use of the `tagged` package on older versons of GHC using `-f-tagged`.
You can disable the use of the `tagged` package using `-f-tagged`.
.
Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.
default: True
manual: True

flag semigroups
description:
You can disable the use of the `semigroups` package on older versons of GHC using `-f-semigroups`.
You can disable the use of the `semigroups` package using `-f-semigroups`.
.
Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.
default: True
manual: True

flag foreign-var
flag StateVar
description:
You can disable the use of the `foreign-var` package on older versons of GHC using `-f-foreign-var`.
You can disable the use of the `StateVar` package using `-f-StateVar`.
.
Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.
default: True
Expand All @@ -59,8 +59,8 @@ library
if flag(semigroups)
build-depends: semigroups >= 0.15.2 && < 1

if flag(foreign-var)
build-depends: foreign-var < 1
if flag(StateVar)
build-depends: StateVar >= 1.1 && < 1.2

if impl(ghc >= 7.4 && < 7.6)
build-depends: ghc-prim
Expand Down
10 changes: 5 additions & 5 deletions src/Data/Functor/Contravariant.hs
Expand Up @@ -92,8 +92,8 @@ import Data.Proxy

import Data.Void

#ifdef MIN_VERSION_foreign_var
import Foreign.Var
#ifdef MIN_VERSION_StateVar
import Data.StateVar
#endif

#if __GLASGOW_HASKELL__ >= 702
Expand Down Expand Up @@ -199,9 +199,9 @@ instance Contravariant f => Contravariant (Reverse f) where
contramap f = Reverse . contramap f . getReverse
{-# INLINE contramap #-}

#ifdef MIN_VERSION_foreign_var
instance Contravariant SettableVar where
contramap f (SettableVar k) = SettableVar (k . f)
#ifdef MIN_VERSION_StateVar
instance Contravariant SettableStateVar where
contramap f (SettableStateVar k) = SettableStateVar (k . f)
{-# INLINE contramap #-}
#endif

Expand Down
18 changes: 9 additions & 9 deletions src/Data/Functor/Contravariant/Divisible.hs
Expand Up @@ -15,8 +15,8 @@ import Data.Monoid

import Data.Void

#if MIN_VERSION_foreign_var
import Foreign.Var
#if MIN_VERSION_StateVar
import Data.StateVar
#endif

--------------------------------------------------------------------------------
Expand Down Expand Up @@ -118,11 +118,11 @@ instance Divisible Predicate where
(b, c) -> g b && h c
conquer = Predicate $ const True

#if MIN_VERSION_foreign_var
instance Divisible SettableVar where
divide k (SettableVar l) (SettableVar r) = SettableVar $ \ a -> case k a of
#if MIN_VERSION_StateVar
instance Divisible SettableStateVar where
divide k (SettableStateVar l) (SettableStateVar r) = SettableStateVar $ \ a -> case k a of
(b, c) -> l b >> r c
conquer = SettableVar $ \_ -> return ()
conquer = SettableStateVar $ \_ -> return ()
#endif

--------------------------------------------------------------------------------
Expand Down Expand Up @@ -193,10 +193,10 @@ instance Monoid r => Decidable (Op r) where
lose f = Op $ absurd . f
choose f (Op g) (Op h) = Op $ either g h . f

#if MIN_VERSION_foreign_var
#if MIN_VERSION_StateVar
instance Decidable SettableVar where
lose k = SettableVar (absurd . k)
choose k (SettableVar l) (SettableVar r) = SettableVar $ \ a -> case k a of
lose k = SettableStateVar (absurd . k)
choose k (SettableStateVar l) (SettableStateVar r) = SettableStateVar $ \ a -> case k a of
Left b -> l b
Right c -> r c
#endif

0 comments on commit aa24021

Please sign in to comment.