1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE FlexibleInstances #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# LANGUAGE ScopedTypeVariables #-}
5 {-# LANGUAGE TypeFamilies #-}
10 import Data.Vector.Fixed (
20 import qualified Data.Vector.Fixed as V (
24 import Data.Vector.Fixed.Boxed
36 -- >>> import Data.Vector.Fixed (mk3)
37 -- >>> let v1 = mk3 1 2 3 :: Vec3 Int
43 (!?) :: (Vector v a) => v a -> Int -> Maybe a
45 | idx < 0 || idx >= V.length v1 = Nothing
46 | otherwise = Just $ v1 V.! idx
49 -- | Remove an element of the given vector.
53 -- >>> import Data.Vector.Fixed (mk3)
54 -- >>> let b = mk3 1 2 3 :: Vec3 Int
55 -- >>> delete b 1 :: Vec2 Int
58 delete :: (Vector v a, Vector w a, Dim v ~ S (Dim w)) => v a -> Int -> w a
60 fromList $ (lhalf ++ rhalf')
62 (lhalf, rhalf) = splitAt idx (toList v1)