# HG changeset patch # User Aleksey Khudyakov # Date 1373381745 -14400 # Branch version-0.5 # Node ID 4c8dd9fb51a7d64ab1b5da896278f9f59fcfbab5 # Parent 133ac9524cd8ce46c774ee2eb160082af4758e50 Implement D.V.F.element in terms of D.V.F.C.element diff --git a/Data/Vector/Fixed/Cont.hs b/Data/Vector/Fixed/Cont.hs --- a/Data/Vector/Fixed/Cont.hs +++ b/Data/Vector/Fixed/Cont.hs @@ -67,7 +67,6 @@ , head , index , element - , lensF -- ** Vector construction , vector , vectorM @@ -575,13 +574,13 @@ => Int -> (a -> f a) -> ContVec n a -> f (ContVec n a) {-# INLINE element #-} element i f v = inspect v - \$ lensF i f mkN + \$ elementF i f mkN -- | Helper for implementation of Twan van Laarhoven lens. -lensF :: forall a n f r. (Arity n,Functor f) - => Int -> (a -> f a) -> Fun n a r -> Fun n a (f r) -lensF n f (Fun fun0) = Fun \$ accum step fini start +elementF :: forall a n f r. (Arity n, Functor f) + => Int -> (a -> f a) -> Fun n a r -> Fun n a (f r) +elementF n f (Fun fun0) = Fun \$ accum step fini start where step :: forall k. T_lens f a r (S k) -> a -> T_lens f a r k step (T_lens (Left (0,fun))) a = T_lens \$ Right \$ fmap fun \$ f a diff --git a/Data/Vector/Fixed/Internal.hs b/Data/Vector/Fixed/Internal.hs --- a/Data/Vector/Fixed/Internal.hs +++ b/Data/Vector/Fixed/Internal.hs @@ -235,8 +235,8 @@ -- | Twan van Laarhoven's lens for element of vector element :: (Vector v a, Functor f) => Int -> (a -> f a) -> (v a -> f (v a)) {-# INLINE element #-} -element i f v = inspect v - \$ C.lensF i f construct +element i f v = C.vector `fmap` (C.element i f \$ C.cvec v) + -- | Left fold over vector