Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed use of `DefaultSignatures` in `Control.Lens.Each` for GHC 7.0.4

  • Loading branch information...
commit 824214ffc6c57c88538b9c1895cce3f62d8a7c2b 1 parent 7b8f570
@ekmett authored
Showing with 32 additions and 6 deletions.
  1. +1 −0  CHANGELOG.markdown
  2. +31 −6 src/Control/Lens/Each.hs
View
1  CHANGELOG.markdown
@@ -2,6 +2,7 @@
-------
* Made the doctest test suite hide all but the exact versions of packages used to build this package to avoid problems with complicated user environments.
* Removed doctests based on `:t` as they are fragile and break across GHC versions.
+* Fixed GHC 7.0.4 compatibility by guarding `DefaultSignatures` in `Control.Lens.Each`.
3.7.1.1 [maintenance release]
-------
View
37 src/Control/Lens/Each.hs
@@ -6,6 +6,11 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
+
+#ifdef DEFAULT_SIGNATURES
+{-# LANGUAGE DefaultSignatures #-}
+#endif
+
#ifndef MIN_VERSION_base
#define MIN_VERSION_base(x,y,z) 1
#endif
@@ -75,9 +80,12 @@ import Data.Array.IArray as IArray
-- ("HELLO","WORLD")
class Each i s t a b | s -> i a, t -> i b, s b -> t, t a -> s where
each :: IndexedTraversal i s t a b
+
+#ifdef DEFAULT_SIGNATURES
default each :: (Traversable f, s ~ f a, t ~ f b) => IndexedTraversal Int s t a b
each = traversed
{-# INLINE each #-}
+#endif
instance (a ~ a', b ~ b') => Each Int (a,a') (b,b') a b where
each = Lens.indexed $ \ f ~(a,b) -> (,) <$> f (0 :: Int) a <*> f 1 b
@@ -133,12 +141,29 @@ instance Each k (HashMap k a) (HashMap k b) a b where
each = Lens.indexed HashMap.traverseWithKey
{-# INLINE each #-}
-instance Each Int [a] [b] a b
-instance Each Int (Identity a) (Identity b) a b
-instance Each Int (Maybe a) (Maybe b) a b
-instance Each Int (Seq a) (Seq b) a b
-instance Each Int (Tree a) (Tree b) a b
-instance Each Int (Vector.Vector a) (Vector.Vector b) a b
+instance Each Int [a] [b] a b where
+ each = traversed
+ {-# INLINE each #-}
+
+instance Each Int (Identity a) (Identity b) a b where
+ each = traversed
+ {-# INLINE each #-}
+
+instance Each Int (Maybe a) (Maybe b) a b where
+ each = traversed
+ {-# INLINE each #-}
+
+instance Each Int (Seq a) (Seq b) a b where
+ each = traversed
+ {-# INLINE each #-}
+
+instance Each Int (Tree a) (Tree b) a b where
+ each = traversed
+ {-# INLINE each #-}
+
+instance Each Int (Vector.Vector a) (Vector.Vector b) a b where
+ each = traversed
+ {-# INLINE each #-}
instance (Prim a, Prim b) => Each Int (Prim.Vector a) (Prim.Vector b) a b where
each = Lens.indexed $ \f v -> Prim.fromListN (Prim.length v) <$> withIndex traversed f (Prim.toList v)
Please sign in to comment.
Something went wrong with that request. Please try again.