summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdwardKmett <>2014-11-26 06:38:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2014-11-26 06:38:00 (GMT)
commit96f5ac8b664c2d71095c9911b3068fb459bc0afe (patch)
treee171b3a81eab8b46db373ab8314c5174ccdcbe97
parentb5ee29e2adf07396a704adde904fc3ce21f89600 (diff)
version 1.0.41.0.4
-rw-r--r--CHANGELOG.markdown4
-rw-r--r--bound.cabal6
-rw-r--r--src/Bound/Scope/Simple.hs27
3 files changed, 34 insertions, 3 deletions
diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown
index da29719..b687a8c 100644
--- a/CHANGELOG.markdown
+++ b/CHANGELOG.markdown
@@ -1,3 +1,7 @@
+1.0.4
+-----
+* Widened version bound on `transformers`.
+
1.0.3
-----
* Added `bitransverseScope`.
diff --git a/bound.cabal b/bound.cabal
index 3e89220..30d953e 100644
--- a/bound.cabal
+++ b/bound.cabal
@@ -1,6 +1,6 @@
name: bound
category: Language, Compilers/Interpreters
-version: 1.0.3
+version: 1.0.4
license: BSD3
cabal-version: >= 1.9.2
license-file: LICENSE
@@ -75,7 +75,7 @@ library
hashable-extras >= 0.1 && < 1,
prelude-extras >= 0.3 && < 1,
profunctors >= 3.3 && < 5,
- transformers >= 0.2 && < 0.4
+ transformers >= 0.2 && < 0.5
ghc-options: -Wall -O2 -fspec-constr -fdicts-cheap -funbox-strict-fields
@@ -86,7 +86,7 @@ test-suite Simple
type: exitcode-stdio-1.0
main-is: Simple.hs
hs-source-dirs: examples
- ghc-options -Wall -threaded
+ ghc-options: -Wall -threaded
if impl(ghc<7.6.1)
ghc-options: -Werror
build-depends:
diff --git a/src/Bound/Scope/Simple.hs b/src/Bound/Scope/Simple.hs
index 239dfff..94b0400 100644
--- a/src/Bound/Scope/Simple.hs
+++ b/src/Bound/Scope/Simple.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE CPP #-}
+{-# LANGUAGE Rank2Types #-}
#if defined(__GLASGOW_HASKELL__)
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
@@ -57,6 +58,10 @@ module Bound.Scope.Simple
, serializeScope
, deserializeScope
, hoistScope
+ , bitraverseScope
+ , bitransverseScope
+ , transverseScope
+ , instantiateVars
) where
import Bound.Class
@@ -356,6 +361,28 @@ traverseScope :: (Applicative g, Traversable f) =>
traverseScope f g (Scope s) = Scope <$> traverse (bitraverse f g) s
{-# INLINE traverseScope #-}
+-- | This allows you to 'bitraverse' a 'Scope'.
+bitraverseScope :: (Bitraversable t, Applicative f) => (k -> f k') -> (a -> f a') -> Scope b (t k) a -> f (Scope b (t k') a')
+bitraverseScope f = bitransverseScope (bitraverse f)
+{-# INLINE bitraverseScope #-}
+
+-- | This is a higher-order analogue of 'traverse'.
+transverseScope :: (Functor f)
+ => (forall r. g r -> f (h r))
+ -> Scope b g a -> f (Scope b h a)
+transverseScope tau (Scope s) = Scope <$> tau s
+
+-- | instantiate bound variables using a list of new variables
+instantiateVars :: Monad t => [a] -> Scope Int t a -> t a
+instantiateVars as = instantiate (vs !!) where
+ vs = map return as
+{-# INLINE instantiateVars #-}
+
+bitransverseScope :: Applicative f => (forall a a'. (a -> f a') -> t a -> f (u a'))
+ -> forall a a'. (a -> f a') -> Scope b t a -> f (Scope b u a')
+bitransverseScope tau f (Scope s) = Scope <$> tau (traverse f) s
+{-# INLINE bitransverseScope #-}
+
-- | mapM over both bound and free variables
mapMBound :: (Monad m, Traversable f) =>
(b -> m c) -> Scope b f a -> m (Scope c f a)