comfort-array-0.5.4.2: Arrays where the index type is a function of the shape type
Safe HaskellSafe-Inferred
LanguageHaskell98

Data.Array.Comfort.Boxed

Synopsis

Documentation

data Array sh a Source #

Instances

Instances details
C sh => Foldable (Array sh) Source # 
Instance details

Defined in Data.Array.Comfort.Boxed.Unchecked

Methods

fold :: Monoid m => Array sh m -> m #

foldMap :: Monoid m => (a -> m) -> Array sh a -> m #

foldMap' :: Monoid m => (a -> m) -> Array sh a -> m #

foldr :: (a -> b -> b) -> b -> Array sh a -> b #

foldr' :: (a -> b -> b) -> b -> Array sh a -> b #

foldl :: (b -> a -> b) -> b -> Array sh a -> b #

foldl' :: (b -> a -> b) -> b -> Array sh a -> b #

foldr1 :: (a -> a -> a) -> Array sh a -> a #

foldl1 :: (a -> a -> a) -> Array sh a -> a #

toList :: Array sh a -> [a] #

null :: Array sh a -> Bool #

length :: Array sh a -> Int #

elem :: Eq a => a -> Array sh a -> Bool #

maximum :: Ord a => Array sh a -> a #

minimum :: Ord a => Array sh a -> a #

sum :: Num a => Array sh a -> a #

product :: Num a => Array sh a -> a #

C sh => Traversable (Array sh) Source # 
Instance details

Defined in Data.Array.Comfort.Boxed.Unchecked

Methods

traverse :: Applicative f => (a -> f b) -> Array sh a -> f (Array sh b) #

sequenceA :: Applicative f => Array sh (f a) -> f (Array sh a) #

mapM :: Monad m => (a -> m b) -> Array sh a -> m (Array sh b) #

sequence :: Monad m => Array sh (m a) -> m (Array sh a) #

Static sh => Applicative (Array sh) Source #

We must restrict Applicative to Static because of pure. Because the shape is static, we do not need a size check in (<*>).

Instance details

Defined in Data.Array.Comfort.Boxed.Unchecked

Methods

pure :: a -> Array sh a #

(<*>) :: Array sh (a -> b) -> Array sh a -> Array sh b #

liftA2 :: (a -> b -> c) -> Array sh a -> Array sh b -> Array sh c #

(*>) :: Array sh a -> Array sh b -> Array sh b #

(<*) :: Array sh a -> Array sh b -> Array sh a #

C sh => Functor (Array sh) Source # 
Instance details

Defined in Data.Array.Comfort.Boxed.Unchecked

Methods

fmap :: (a -> b) -> Array sh a -> Array sh b #

(<$) :: a -> Array sh b -> Array sh a #

(C sh, Show sh, Show a) => Show (Array sh a) Source # 
Instance details

Defined in Data.Array.Comfort.Boxed.Unchecked

Methods

showsPrec :: Int -> Array sh a -> ShowS #

show :: Array sh a -> String #

showList :: [Array sh a] -> ShowS #

(C sh, NFData sh, NFData a) => NFData (Array sh a) Source # 
Instance details

Defined in Data.Array.Comfort.Boxed.Unchecked

Methods

rnf :: Array sh a -> () #

(Eq sh, Eq a) => Eq (Array sh a) Source # 
Instance details

Defined in Data.Array.Comfort.Boxed.Unchecked

Methods

(==) :: Array sh a -> Array sh a -> Bool #

(/=) :: Array sh a -> Array sh a -> Bool #

shape :: Array sh a -> sh Source #

reshape :: (C sh0, C sh1) => sh1 -> Array sh0 a -> Array sh1 a Source #

mapShape :: (C sh0, C sh1) => (sh0 -> sh1) -> Array sh0 a -> Array sh1 a Source #

accessMaybe :: Indexed sh => Array sh a -> Index sh -> Maybe a Source #

(!) :: Indexed sh => Array sh a -> Index sh -> a infixl 9 Source #

toList :: C sh => Array sh a -> [a] Source #

fromList :: C sh => sh -> [a] -> Array sh a Source #

toAssociations :: Indexed sh => Array sh a -> [(Index sh, a)] Source #

fromMap :: Ord k => Map k a -> Array (Set k) a Source #

toMap :: Ord k => Array (Set k) a -> Map k a Source #

fromTuple :: NestedTuple tuple => DataTuple tuple a -> Array (NestedTuple ixtype tuple) a Source #

toTuple :: NestedTuple tuple => Array (NestedTuple ixtype tuple) a -> DataTuple tuple a Source #

fromRecord :: Traversable f => f a -> Array (Record f) a Source #

toRecord :: Traversable f => Array (Record f) a -> f a Source #

fromContainer :: C f => f a -> Array (Shape f) a Source #

toContainer :: C f => Array (Shape f) a -> f a Source #

indices :: Indexed sh => sh -> Array sh (Index sh) Source #

replicate :: C sh => sh -> a -> Array sh a Source #

cartesian :: (C sh0, C sh1) => Array sh0 a -> Array sh1 b -> Array (sh0, sh1) (a, b) Source #

map :: C sh => (a -> b) -> Array sh a -> Array sh b Source #

zipWith :: (C sh, Eq sh) => (a -> b -> c) -> Array sh a -> Array sh b -> Array sh c Source #

(//) :: Indexed sh => Array sh a -> [(Index sh, a)] -> Array sh a Source #

accumulate :: Indexed sh => (a -> b -> a) -> Array sh a -> [(Index sh, b)] -> Array sh a Source #

fromAssociations :: Indexed sh => a -> sh -> [(Index sh, a)] -> Array sh a Source #

pick :: (Indexed sh0, C sh1) => Array (sh0, sh1) a -> Index sh0 -> Array sh1 a Source #

:{

QC.forAll genArray2 $ xs -> let shape = Array.shape xs in Shape.size shape > 0 QC.==> QC.forAll (QC.elements $ Shape.indices shape) $ (ix0,ix1) -> Array.pick xs ix0 ! ix1 == xs!(ix0,ix1) :}

append :: (C shx, C shy) => Array shx a -> Array shy a -> Array (shx ::+ shy) a infixr 5 Source #

take :: Integral n => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a Source #

\(QC.NonNegative n) (ArrayChar x)  ->  x == Array.mapShape (Shape.ZeroBased . Shape.size) (Array.append (Array.take n x) (Array.drop n x))

drop :: Integral n => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a Source #

\(QC.NonNegative n) (ArrayChar x)  ->  x == Array.mapShape (Shape.ZeroBased . Shape.size) (Array.append (Array.take n x) (Array.drop n x))

takeLeft :: (C sh0, C sh1) => Array (sh0 ::+ sh1) a -> Array sh0 a Source #

\(ArrayChar x) (ArrayChar y) -> let xy = Array.append x y in x == Array.takeLeft xy  &&  y == Array.takeRight xy

takeRight :: (C sh0, C sh1) => Array (sh0 ::+ sh1) a -> Array sh1 a Source #

split :: (C sh0, C sh1) => Array (sh0 ::+ sh1) a -> (Array sh0 a, Array sh1 a) Source #

takeCenter :: (C sh0, C sh1, C sh2) => Array (sh0 ::+ (sh1 ::+ sh2)) a -> Array sh1 a Source #

\(ArrayChar x) (ArrayChar y) (ArrayChar z) -> let xyz = Array.append x $ Array.append y z in y == Array.takeCenter xyz