{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Data.RAVec.Lens (
ix,
) where
import Control.Applicative ((<$>))
import Data.Bin.Pos (Pos (..))
import Prelude ()
import qualified Control.Lens as L
import qualified Data.RAVec.NonEmpty.Lens as NE
import Data.RAVec
ix :: Pos b -> L.Lens' (RAVec b a) a
ix (Pos n) f (NonEmpty x) = NonEmpty <$> NE.ix n f x
instance L.FunctorWithIndex (Pos b) (RAVec b) where
imap = imap
instance L.FoldableWithIndex (Pos b) (RAVec b) where
ifoldMap = ifoldMap
ifoldr = ifoldr
instance L.TraversableWithIndex (Pos b) (RAVec b) where
itraverse = itraverse
instance L.Each (RAVec n a) (RAVec n b) a b where
each = traverse
type instance L.Index (RAVec n a) = Pos n
type instance L.IxValue (RAVec n a) = a
instance L.Ixed (RAVec b a) where
ix = ix