-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Arrays where the index type is a function of the shape type -- -- Arrays from the basic array package are already very powerful -- compared with arrays in other languages. They may have any number of -- dimensions, are type safe and defined in a uniform way using the Ix -- class with free choice of the lower bounds (0, 1, or whatever you -- like). -- -- This package goes one step further: The shape and the index type are -- different, but the index type is a type function of the shape type. -- This offers much more flexibility and type safety. -- -- Some examples are: -- --
-- Shape> let sh2 = (ZeroBased (2::Int), ZeroBased (2::Int)) -- Shape> let sh3 = (ZeroBased (3::Int), ZeroBased (3::Int)) -- Shape> offset sh3 $ indexFromOffset sh2 3 -- 4 -- Shape> offset (Deferred sh3) $ indexFromOffset (Deferred sh2) 3 -- 3 --newtype Deferred sh Deferred :: sh -> Deferred sh -- | DeferredIndex has an Ord instance that is based on the -- storage order in memory. This way, you can put DeferredIndex -- values in a Set or use them as keys in a Map even if -- Index sh has no Ord instance. The downside is, that -- the ordering of DeferredIndex sh may differ from the one of -- Index sh. newtype DeferredIndex sh DeferredIndex :: Int -> DeferredIndex sh deferIndex :: (Indexed sh, Index sh ~ ix) => sh -> ix -> DeferredIndex sh revealIndex :: (InvIndexed sh, Index sh ~ ix) => sh -> DeferredIndex sh -> ix data sh0 :+: sh1 (:+:) :: sh0 -> sh1 -> (:+:) sh0 sh1 infixr 5 :+: infixr 5 :+: data Triangular part size Triangular :: part -> size -> Triangular part size [triangularPart] :: Triangular part size -> part [triangularSize] :: Triangular part size -> size data Lower Lower :: Lower data Upper Upper :: Upper type LowerTriangular = Triangular Lower type UpperTriangular = Triangular Upper lowerTriangular :: size -> LowerTriangular size upperTriangular :: size -> UpperTriangular size triangleSize :: Int -> Int triangleRoot :: Floating a => a -> a instance (GHC.Show.Show sh0, GHC.Show.Show sh1) => GHC.Show.Show (sh0 Data.Array.Comfort.Shape.:+: sh1) instance (GHC.Classes.Eq sh0, GHC.Classes.Eq sh1) => GHC.Classes.Eq (sh0 Data.Array.Comfort.Shape.:+: sh1) instance (GHC.Show.Show part, GHC.Show.Show size) => GHC.Show.Show (Data.Array.Comfort.Shape.Triangular part size) instance GHC.Show.Show Data.Array.Comfort.Shape.Upper instance GHC.Classes.Eq Data.Array.Comfort.Shape.Upper instance GHC.Show.Show Data.Array.Comfort.Shape.Lower instance GHC.Classes.Eq Data.Array.Comfort.Shape.Lower instance GHC.Show.Show (Data.Array.Comfort.Shape.DeferredIndex sh) instance GHC.Classes.Ord (Data.Array.Comfort.Shape.DeferredIndex sh) instance GHC.Classes.Eq (Data.Array.Comfort.Shape.DeferredIndex sh) instance GHC.Show.Show sh => GHC.Show.Show (Data.Array.Comfort.Shape.Deferred sh) instance GHC.Classes.Eq sh => GHC.Classes.Eq (Data.Array.Comfort.Shape.Deferred sh) instance GHC.Show.Show (Data.Array.Comfort.Shape.Enumeration n) instance GHC.Classes.Eq (Data.Array.Comfort.Shape.Enumeration n) instance GHC.Show.Show n => GHC.Show.Show (Data.Array.Comfort.Shape.Shifted n) instance GHC.Classes.Eq n => GHC.Classes.Eq (Data.Array.Comfort.Shape.Shifted n) instance GHC.Show.Show n => GHC.Show.Show (Data.Array.Comfort.Shape.Range n) instance GHC.Classes.Eq n => GHC.Classes.Eq (Data.Array.Comfort.Shape.Range n) instance GHC.Show.Show n => GHC.Show.Show (Data.Array.Comfort.Shape.OneBased n) instance GHC.Classes.Eq n => GHC.Classes.Eq (Data.Array.Comfort.Shape.OneBased n) instance GHC.Show.Show n => GHC.Show.Show (Data.Array.Comfort.Shape.ZeroBased n) instance GHC.Classes.Eq n => GHC.Classes.Eq (Data.Array.Comfort.Shape.ZeroBased n) instance GHC.Show.Show Data.Array.Comfort.Shape.Zero instance GHC.Classes.Ord Data.Array.Comfort.Shape.Zero instance GHC.Classes.Eq Data.Array.Comfort.Shape.Zero instance (Control.DeepSeq.NFData sh0, Control.DeepSeq.NFData sh1) => Control.DeepSeq.NFData (sh0 Data.Array.Comfort.Shape.:+: sh1) instance (Data.Array.Comfort.Shape.C sh0, Data.Array.Comfort.Shape.C sh1) => Data.Array.Comfort.Shape.C (sh0 Data.Array.Comfort.Shape.:+: sh1) instance (Data.Array.Comfort.Shape.Indexed sh0, Data.Array.Comfort.Shape.Indexed sh1) => Data.Array.Comfort.Shape.Indexed (sh0 Data.Array.Comfort.Shape.:+: sh1) instance (Data.Array.Comfort.Shape.InvIndexed sh0, Data.Array.Comfort.Shape.InvIndexed sh1) => Data.Array.Comfort.Shape.InvIndexed (sh0 Data.Array.Comfort.Shape.:+: sh1) instance (Data.Array.Comfort.Shape.Static sh0, Data.Array.Comfort.Shape.Static sh1) => Data.Array.Comfort.Shape.Static (sh0 Data.Array.Comfort.Shape.:+: sh1) instance (Data.Array.Comfort.Shape.TriangularPart part, Control.DeepSeq.NFData size) => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.Triangular part size) instance (Data.Array.Comfort.Shape.TriangularPart part, GHC.Classes.Eq size) => GHC.Classes.Eq (Data.Array.Comfort.Shape.Triangular part size) instance (Data.Array.Comfort.Shape.TriangularPart part, Data.Array.Comfort.Shape.C size) => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Triangular part size) instance (Data.Array.Comfort.Shape.TriangularPart part, Data.Array.Comfort.Shape.Indexed size) => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Triangular part size) instance (Data.Array.Comfort.Shape.TriangularPart part, Data.Array.Comfort.Shape.InvIndexed size) => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Triangular part size) instance (Data.Array.Comfort.Shape.TriangularPart part, Data.Array.Comfort.Shape.Static size) => Data.Array.Comfort.Shape.Static (Data.Array.Comfort.Shape.Triangular part size) instance Data.Array.Comfort.Shape.TriangularPart Data.Array.Comfort.Shape.Lower instance Data.Array.Comfort.Shape.TriangularPart Data.Array.Comfort.Shape.Upper instance Data.Array.Comfort.Shape.C sh => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Deferred sh) instance Data.Array.Comfort.Shape.C sh => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Deferred sh) instance Foreign.Storable.Storable (Data.Array.Comfort.Shape.DeferredIndex sh) instance Control.DeepSeq.NFData sh => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.Deferred sh) instance Data.Array.Comfort.Shape.C sh => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Deferred sh) instance Data.Array.Comfort.Shape.Static sh => Data.Array.Comfort.Shape.Static (Data.Array.Comfort.Shape.Deferred sh) instance Control.DeepSeq.NFData (Data.Array.Comfort.Shape.Enumeration n) instance (GHC.Enum.Enum n, GHC.Enum.Bounded n) => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Enumeration n) instance (GHC.Enum.Enum n, GHC.Enum.Bounded n) => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Enumeration n) instance (GHC.Enum.Enum n, GHC.Enum.Bounded n) => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Enumeration n) instance (GHC.Enum.Enum n, GHC.Enum.Bounded n) => Data.Array.Comfort.Shape.Static (Data.Array.Comfort.Shape.Enumeration n) instance Foreign.Storable.Storable (Data.Array.Comfort.Shape.Enumeration n) instance GHC.Real.Integral n => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.ZeroBased n) instance GHC.Real.Integral n => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.OneBased n) instance GHC.Base.Functor Data.Array.Comfort.Shape.Shifted instance Control.DeepSeq.NFData n => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.Shifted n) instance GHC.Real.Integral n => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Shifted n) instance GHC.Real.Integral n => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Shifted n) instance GHC.Real.Integral n => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Shifted n) instance Foreign.Storable.Storable n => Foreign.Storable.Storable (Data.Array.Comfort.Shape.Shifted n) instance GHC.Base.Functor Data.Array.Comfort.Shape.Range instance Control.DeepSeq.NFData n => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.Range n) instance GHC.Arr.Ix n => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Range n) instance GHC.Arr.Ix n => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Range n) instance GHC.Arr.Ix n => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Range n) instance Foreign.Storable.Storable n => Foreign.Storable.Storable (Data.Array.Comfort.Shape.Range n) instance GHC.Base.Functor Data.Array.Comfort.Shape.OneBased instance GHC.Base.Applicative Data.Array.Comfort.Shape.OneBased instance Control.DeepSeq.NFData n => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.OneBased n) instance Foreign.Storable.Storable n => Foreign.Storable.Storable (Data.Array.Comfort.Shape.OneBased n) instance GHC.Real.Integral n => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.OneBased n) instance GHC.Real.Integral n => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.OneBased n) instance GHC.Base.Functor Data.Array.Comfort.Shape.ZeroBased instance GHC.Base.Applicative Data.Array.Comfort.Shape.ZeroBased instance Control.DeepSeq.NFData n => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.ZeroBased n) instance Foreign.Storable.Storable n => Foreign.Storable.Storable (Data.Array.Comfort.Shape.ZeroBased n) instance GHC.Real.Integral n => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.ZeroBased n) instance GHC.Real.Integral n => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.ZeroBased n) instance Data.Array.Comfort.Shape.C Data.Array.Comfort.Shape.Zero instance Data.Array.Comfort.Shape.Static Data.Array.Comfort.Shape.Zero instance Data.Array.Comfort.Shape.Static () instance Data.Array.Comfort.Shape.Static sh => Data.Array.Comfort.Shape.Static (Data.Tagged.Tagged s sh) instance (Data.Array.Comfort.Shape.Static sh0, Data.Array.Comfort.Shape.Static sh1) => Data.Array.Comfort.Shape.Static (sh0, sh1) instance (Data.Array.Comfort.Shape.Static sh0, Data.Array.Comfort.Shape.Static sh1, Data.Array.Comfort.Shape.Static sh2) => Data.Array.Comfort.Shape.Static (sh0, sh1, sh2) instance Data.Array.Comfort.Shape.InvIndexed () instance GHC.Classes.Ord n => Data.Array.Comfort.Shape.InvIndexed (Data.Set.Internal.Set n) instance Data.Array.Comfort.Shape.InvIndexed sh => Data.Array.Comfort.Shape.InvIndexed (Data.Tagged.Tagged s sh) instance (Data.Array.Comfort.Shape.InvIndexed sh0, Data.Array.Comfort.Shape.InvIndexed sh1) => Data.Array.Comfort.Shape.InvIndexed (sh0, sh1) instance (Data.Array.Comfort.Shape.InvIndexed sh0, Data.Array.Comfort.Shape.InvIndexed sh1, Data.Array.Comfort.Shape.InvIndexed sh2) => Data.Array.Comfort.Shape.InvIndexed (sh0, sh1, sh2) instance Data.Array.Comfort.Shape.Indexed () instance GHC.Classes.Ord n => Data.Array.Comfort.Shape.Indexed (Data.Set.Internal.Set n) instance Data.Array.Comfort.Shape.Indexed sh => Data.Array.Comfort.Shape.Indexed (Data.Tagged.Tagged s sh) instance (Data.Array.Comfort.Shape.Indexed sh0, Data.Array.Comfort.Shape.Indexed sh1) => Data.Array.Comfort.Shape.Indexed (sh0, sh1) instance (Data.Array.Comfort.Shape.Indexed sh0, Data.Array.Comfort.Shape.Indexed sh1, Data.Array.Comfort.Shape.Indexed sh2) => Data.Array.Comfort.Shape.Indexed (sh0, sh1, sh2) instance Data.Array.Comfort.Shape.C () instance GHC.Classes.Ord n => Data.Array.Comfort.Shape.C (Data.Set.Internal.Set n) instance Data.Array.Comfort.Shape.C sh => Data.Array.Comfort.Shape.C (Data.Tagged.Tagged s sh) instance (Data.Array.Comfort.Shape.C sh0, Data.Array.Comfort.Shape.C sh1) => Data.Array.Comfort.Shape.C (sh0, sh1) instance (Data.Array.Comfort.Shape.C sh0, Data.Array.Comfort.Shape.C sh1, Data.Array.Comfort.Shape.C sh2) => Data.Array.Comfort.Shape.C (sh0, sh1, sh2) module Data.Array.Comfort.Shape.Test tests :: (InvIndexed sh, Show sh, Index sh ~ ix, Eq ix, Show ix) => Gen sh -> [(String, Property)] -- | This module provides an array shape type, that allows to store -- elements from a container while preserving the container structure. module Data.Array.Comfort.Container class (Foldable f) => C f where { data family Shape f; } shapeSize :: C f => Shape f -> Int fromList :: C f => Shape f -> [a] -> f a toShape :: C f => f a -> Shape f class (C f) => EqShape f eqShape :: EqShape f => Shape f -> Shape f -> Bool class (C f) => NFShape f rnfShape :: NFShape f => Shape f -> () instance GHC.Show.Show (Data.Array.Comfort.Container.Shape []) instance GHC.Show.Show (Data.Array.Comfort.Container.Shape Data.Empty.T) instance GHC.Show.Show k => GHC.Show.Show (Data.Array.Comfort.Container.Shape (Data.Map.Internal.Map k)) instance GHC.Show.Show k => GHC.Show.Show (Data.Array.Comfort.Container.Shape (Data.NonEmpty.Map.T k)) instance Data.Array.Comfort.Container.EqShape f => GHC.Classes.Eq (Data.Array.Comfort.Container.Shape f) instance Data.Array.Comfort.Container.EqShape [] instance Data.Array.Comfort.Container.EqShape f => Data.Array.Comfort.Container.EqShape (Data.NonEmptyPrivate.T f) instance Data.Array.Comfort.Container.EqShape Data.Empty.T instance GHC.Classes.Ord k => Data.Array.Comfort.Container.EqShape (Data.Map.Internal.Map k) instance GHC.Classes.Ord k => Data.Array.Comfort.Container.EqShape (Data.NonEmpty.Map.T k) instance Data.Array.Comfort.Container.NFShape f => Control.DeepSeq.NFData (Data.Array.Comfort.Container.Shape f) instance Data.Array.Comfort.Container.NFShape [] instance Data.Array.Comfort.Container.NFShape f => Data.Array.Comfort.Container.NFShape (Data.NonEmptyPrivate.T f) instance Data.Array.Comfort.Container.NFShape Data.Empty.T instance (Control.DeepSeq.NFData k, GHC.Classes.Ord k) => Data.Array.Comfort.Container.NFShape (Data.Map.Internal.Map k) instance (Control.DeepSeq.NFData k, GHC.Classes.Ord k) => Data.Array.Comfort.Container.NFShape (Data.NonEmpty.Map.T k) instance Data.Array.Comfort.Container.C f => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Container.Shape f) instance Data.Array.Comfort.Container.C [] instance Data.Array.Comfort.Container.C f => Data.Array.Comfort.Container.C (Data.NonEmptyPrivate.T f) instance Data.Array.Comfort.Container.C Data.Empty.T instance GHC.Classes.Ord k => Data.Array.Comfort.Container.C (Data.Map.Internal.Map k) instance GHC.Classes.Ord k => Data.Array.Comfort.Container.C (Data.NonEmpty.Map.T k) module Data.Array.Comfort.Boxed data Array sh a shape :: Array sh a -> sh reshape :: (C sh0, C sh1) => sh1 -> Array sh0 a -> Array sh1 a mapShape :: (C sh0, C sh1) => (sh0 -> sh1) -> Array sh0 a -> Array sh1 a (!) :: Indexed sh => Array sh a -> Index sh -> a infixl 9 ! toList :: C sh => Array sh a -> [a] fromList :: C sh => sh -> [a] -> Array sh a vectorFromList :: [a] -> Array (ZeroBased Int) a toAssociations :: Indexed sh => Array sh a -> [(Index sh, a)] fromMap :: Ord k => Map k a -> Array (Set k) a toMap :: Ord k => Array (Set k) a -> Map k a fromContainer :: C f => f a -> Array (Shape f) a toContainer :: C f => Array (Shape f) a -> f a indices :: Indexed sh => sh -> Array sh (Index sh) replicate :: C sh => sh -> a -> Array sh a map :: C sh => (a -> b) -> Array sh a -> Array sh b zipWith :: (C sh, Eq sh) => (a -> b -> c) -> Array sh a -> Array sh b -> Array sh c (//) :: Indexed sh => Array sh a -> [(Index sh, a)] -> Array sh a accumulate :: Indexed sh => (a -> b -> a) -> Array sh a -> [(Index sh, b)] -> Array sh a fromAssociations :: Indexed sh => a -> sh -> [(Index sh, a)] -> Array sh a module Data.Array.Comfort.Storable.Mutable.Private data Array (m :: * -> *) sh a Array :: sh -> MutablePtr a -> Array sh a [shape] :: Array sh a -> sh [buffer] :: Array sh a -> MutablePtr a type STArray s = Array (ST s) type IOArray = Array IO copy :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m (Array m sh a) create :: (C sh, Storable a) => sh -> (Ptr a -> IO ()) -> IO (IOArray sh a) createWithSize :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> IO (IOArray sh a) createWithSizeAndResult :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> IO (IOArray sh a, b) unsafeCreate :: (PrimMonad m, C sh, Storable a) => sh -> (Ptr a -> IO ()) -> m (Array m sh a) unsafeCreateWithSize :: (PrimMonad m, C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> m (Array m sh a) unsafeCreateWithSizeAndResult :: (PrimMonad m, C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> m (Array m sh a, b) unsafeArrayIOToPrim :: PrimMonad m => IOArray sh a -> Array m sh a show :: (PrimMonad m, C sh, Show sh, Storable a, Show a) => Array m sh a -> m String withArrayPtr :: PrimMonad m => MutablePtr a -> (Ptr a -> IO b) -> m b withPtr :: PrimMonad m => Array m sh a -> (Ptr a -> IO b) -> m b read :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> m a write :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> a -> m () update :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> (a -> a) -> m () new :: (PrimMonad m, C sh, Storable a) => sh -> a -> m (Array m sh a) toList :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m [a] fromList :: (PrimMonad m, C sh, Storable a) => sh -> [a] -> m (Array m sh a) vectorFromList :: (PrimMonad m, Storable a) => [a] -> m (Array m (ZeroBased Int) a) module Data.Array.Comfort.Storable.Private data Array sh a Array :: sh -> ForeignPtr a -> Array sh a [shape] :: Array sh a -> sh [buffer] :: Array sh a -> ForeignPtr a reshape :: sh1 -> Array sh0 a -> Array sh1 a mapShape :: (sh0 -> sh1) -> Array sh0 a -> Array sh1 a (!) :: (Indexed sh, Storable a) => Array sh a -> Index sh -> a infixl 9 ! toList :: (C sh, Storable a) => Array sh a -> [a] fromList :: (C sh, Storable a) => sh -> [a] -> Array sh a vectorFromList :: Storable a => [a] -> Array (ZeroBased Int) a (//) :: (Indexed sh, Storable a) => Array sh a -> [(Index sh, a)] -> Array sh a accumulate :: (Indexed sh, Storable a) => (a -> b -> a) -> Array sh a -> [(Index sh, b)] -> Array sh a fromAssociations :: (Indexed sh, Storable a) => a -> sh -> [(Index sh, a)] -> Array sh a freeze :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m (Array sh a) thaw :: (PrimMonad m, C sh, Storable a) => Array sh a -> m (Array m sh a) unsafeFreeze :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m (Array sh a) unsafeThaw :: (PrimMonad m, C sh, Storable a) => Array sh a -> m (Array m sh a) instance (Data.Array.Comfort.Shape.C sh, GHC.Show.Show sh, Foreign.Storable.Storable a, GHC.Show.Show a) => GHC.Show.Show (Data.Array.Comfort.Storable.Private.Array sh a) instance Control.DeepSeq.NFData sh => Control.DeepSeq.NFData (Data.Array.Comfort.Storable.Private.Array sh a) instance (Data.Array.Comfort.Shape.C sh, GHC.Classes.Eq sh, Foreign.Storable.Storable a, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Array.Comfort.Storable.Private.Array sh a) -- | The functions in this module miss any bound checking. module Data.Array.Comfort.Storable.Mutable.Unchecked data Array (m :: * -> *) sh a Array :: sh -> MutablePtr a -> Array sh a [shape] :: Array sh a -> sh [buffer] :: Array sh a -> MutablePtr a type STArray s = Array (ST s) type IOArray = Array IO new :: (PrimMonad m, C sh, Storable a) => sh -> a -> m (Array m sh a) copy :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m (Array m sh a) create :: (C sh, Storable a) => sh -> (Ptr a -> IO ()) -> IO (IOArray sh a) createWithSize :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> IO (IOArray sh a) createWithSizeAndResult :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> IO (IOArray sh a, b) unsafeCreate :: (PrimMonad m, C sh, Storable a) => sh -> (Ptr a -> IO ()) -> m (Array m sh a) unsafeCreateWithSize :: (PrimMonad m, C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> m (Array m sh a) unsafeCreateWithSizeAndResult :: (PrimMonad m, C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> m (Array m sh a, b) withPtr :: PrimMonad m => Array m sh a -> (Ptr a -> IO b) -> m b read :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> m a write :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> a -> m () update :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> (a -> a) -> m () toList :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m [a] fromList :: (PrimMonad m, C sh, Storable a) => sh -> [a] -> m (Array m sh a) vectorFromList :: (PrimMonad m, Storable a) => [a] -> m (Array m (ZeroBased Int) a) freeze :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m (Array sh a) unsafeFreeze :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m (Array sh a) thaw :: (PrimMonad m, C sh, Storable a) => Array sh a -> m (Array m sh a) unsafeThaw :: (PrimMonad m, C sh, Storable a) => Array sh a -> m (Array m sh a) module Data.Array.Comfort.Storable.Mutable data Array (m :: * -> *) sh a type STArray s = Array (ST s) type IOArray = Array IO shape :: Array m sh a -> sh new :: (PrimMonad m, C sh, Storable a) => sh -> a -> m (Array m sh a) read :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> m a write :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> a -> m () update :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> (a -> a) -> m () toList :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m [a] fromList :: (PrimMonad m, C sh, Storable a) => sh -> [a] -> m (Array m sh a) vectorFromList :: (PrimMonad m, Storable a) => [a] -> m (Array m (ZeroBased Int) a) thaw :: (PrimMonad m, C sh, Storable a) => Array sh a -> m (Array m sh a) freeze :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m (Array sh a) module Data.Array.Comfort.Storable.Unchecked.Monadic unsafeCreate :: (PrimMonad m, C sh, Storable a) => sh -> (Ptr a -> IO ()) -> m (Array sh a) unsafeCreateWithSize :: (PrimMonad m, C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> m (Array sh a) unsafeCreateWithSizeAndResult :: (PrimMonad m, C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> m (Array sh a, b) -- | The functions in this module miss any bound checking. module Data.Array.Comfort.Storable.Unchecked data Array sh a Array :: sh -> ForeignPtr a -> Array sh a [shape] :: Array sh a -> sh [buffer] :: Array sh a -> ForeignPtr a reshape :: sh1 -> Array sh0 a -> Array sh1 a mapShape :: (sh0 -> sh1) -> Array sh0 a -> Array sh1 a (!) :: (Indexed sh, Storable a) => Array sh a -> Index sh -> a infixl 9 ! unsafeCreate :: (C sh, Storable a) => sh -> (Ptr a -> IO ()) -> Array sh a unsafeCreateWithSize :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> Array sh a unsafeCreateWithSizeAndResult :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> (Array sh a, b) toList :: (C sh, Storable a) => Array sh a -> [a] fromList :: (C sh, Storable a) => sh -> [a] -> Array sh a vectorFromList :: Storable a => [a] -> Array (ZeroBased Int) a map :: (C sh, Storable a, Storable b) => (a -> b) -> Array sh a -> Array sh b mapWithIndex :: (Indexed sh, Index sh ~ ix, Storable a, Storable b) => (ix -> a -> b) -> Array sh a -> Array sh b zipWith :: (C sh, Storable a, Storable b, Storable c) => (a -> b -> c) -> Array sh a -> Array sh b -> Array sh c (//) :: (Indexed sh, Storable a) => Array sh a -> [(Index sh, a)] -> Array sh a accumulate :: (Indexed sh, Storable a) => (a -> b -> a) -> Array sh a -> [(Index sh, b)] -> Array sh a fromAssociations :: (Indexed sh, Storable a) => a -> sh -> [(Index sh, a)] -> Array sh a singleton :: Storable a => a -> Array () a append :: (C shx, C shy, Storable a) => Array shx a -> Array shy a -> Array (shx :+: shy) a take :: (Integral n, Storable a) => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a drop :: (Integral n, Storable a) => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a takeLeft :: (C sh0, C sh1, Storable a) => Array (sh0 :+: sh1) a -> Array sh0 a takeRight :: (C sh0, C sh1, Storable a) => Array (sh0 :+: sh1) a -> Array sh1 a split :: (C sh0, C sh1, Storable a) => Array (sh0 :+: sh1) a -> (Array sh0 a, Array sh1 a) sum :: (C sh, Storable a, Num a) => Array sh a -> a product :: (C sh, Storable a, Num a) => Array sh a -> a foldl :: (C sh, Storable a) => (b -> a -> b) -> b -> Array sh a -> b module Data.Array.Comfort.Storable data Array sh a shape :: Array sh a -> sh reshape :: (C sh0, C sh1) => sh1 -> Array sh0 a -> Array sh1 a mapShape :: (C sh0, C sh1) => (sh0 -> sh1) -> Array sh0 a -> Array sh1 a (!) :: (Indexed sh, Storable a) => Array sh a -> Index sh -> a infixl 9 ! toList :: (C sh, Storable a) => Array sh a -> [a] vectorFromList :: Storable a => [a] -> Array (ZeroBased Int) a toAssociations :: (Indexed sh, Storable a) => Array sh a -> [(Index sh, a)] fromList :: (C sh, Storable a) => sh -> [a] -> Array sh a fromMap :: (Ord k, Storable a) => Map k a -> Array (Set k) a fromContainer :: (C f, Storable a) => f a -> Array (Shape f) a toContainer :: (C f, Storable a) => Array (Shape f) a -> f a sample :: (Indexed sh, Storable a) => sh -> (Index sh -> a) -> Array sh a fromBoxed :: (C sh, Storable a) => Array sh a -> Array sh a toBoxed :: (C sh, Storable a) => Array sh a -> Array sh a map :: (C sh, Storable a, Storable b) => (a -> b) -> Array sh a -> Array sh b mapWithIndex :: (Indexed sh, Index sh ~ ix, Storable a, Storable b) => (ix -> a -> b) -> Array sh a -> Array sh b zipWith :: (C sh, Eq sh, Storable a, Storable b, Storable c) => (a -> b -> c) -> Array sh a -> Array sh b -> Array sh c (//) :: (Indexed sh, Storable a) => Array sh a -> [(Index sh, a)] -> Array sh a accumulate :: (Indexed sh, Storable a) => (a -> b -> a) -> Array sh a -> [(Index sh, b)] -> Array sh a fromAssociations :: (Indexed sh, Storable a) => a -> sh -> [(Index sh, a)] -> Array sh a singleton :: Storable a => a -> Array () a append :: (C shx, C shy, Storable a) => Array shx a -> Array shy a -> Array (shx :+: shy) a take :: (Integral n, Storable a) => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a drop :: (Integral n, Storable a) => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a takeLeft :: (C sh0, C sh1, Storable a) => Array (sh0 :+: sh1) a -> Array sh0 a takeRight :: (C sh0, C sh1, Storable a) => Array (sh0 :+: sh1) a -> Array sh1 a split :: (C sh0, C sh1, Storable a) => Array (sh0 :+: sh1) a -> (Array sh0 a, Array sh1 a) sum :: (C sh, Storable a, Num a) => Array sh a -> a product :: (C sh, Storable a, Num a) => Array sh a -> a -- | It is a checked error if the vector is empty. minimum :: (C sh, Storable a, Ord a) => Array sh a -> a argMinimum :: (InvIndexed sh, Index sh ~ ix, Storable a, Ord a) => Array sh a -> (ix, a) -- | It is a checked error if the vector is empty. maximum :: (C sh, Storable a, Ord a) => Array sh a -> a argMaximum :: (InvIndexed sh, Index sh ~ ix, Storable a, Ord a) => Array sh a -> (ix, a) -- |
-- limits x = (minimum x, maximum x) --limits :: (C sh, Storable a, Ord a) => Array sh a -> (a, a) foldl :: (C sh, Storable a) => (b -> a -> b) -> b -> Array sh a -> b foldl1 :: (C sh, Storable a) => (a -> a -> a) -> Array sh a -> a foldMap :: (C sh, Storable a, Ord a, Semigroup m) => (a -> m) -> Array sh a -> m