{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Data.RAVec.Optics (
ix,
) where
import Control.Applicative ((<$>))
import Data.Bin.Pos (Pos (..))
import Data.RAVec.NonEmpty.Optics ()
import qualified Data.RAVec.NonEmpty.Optics.Internal as NE
import qualified Optics.Core as L
import Data.RAVec
ix :: Pos b -> L.Lens' (RAVec b a) a
ix i = L.lensVL (ixVL i)
ixVL :: Functor f => Pos b -> NE.LensLikeVL' f (RAVec b a) a
ixVL (Pos n) f (NonEmpty x) = NonEmpty <$> NE.ixVL 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 (Pos n) (RAVec n a) (RAVec n b) a b where
type instance L.Index (RAVec n a) = Pos n
type instance L.IxValue (RAVec n a) = a
instance L.Ixed (RAVec b a) where
type IxKind (RAVec b a) = L.A_Lens
ix = ix