1. Aleksey Khudyakov
  2. fixed-vector

Commits

Aleksey Khudyakov  committed 133ac95

Add lens for ContVec

  • Participants
  • Parent commits 97e3952
  • Branches version-0.5

Comments (0)

Files changed (1)

File Data/Vector/Fixed/Cont.hs

View file
     -- ** Getters
   , head
   , index
+  , element
   , lensF
     -- ** Vector construction
   , vector
 
 newtype T_Index a n = T_Index (Either Int a)
 
+
+-- | Twan van Laarhoven lens for continuation based vector
+element :: forall n a f. (Arity n, Functor f)
+        => Int -> (a -> f a) -> ContVec n a -> f (ContVec n a)
+{-# INLINE element #-}
+element i f v = inspect v
+              $ lensF 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)